如何在YAML中进行字符串连接或字符串替换? [英] How can I do string concatenation, or string replacement in YAML?

查看:1420
本文介绍了如何在YAML中进行字符串连接或字符串替换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个:

user_dir: /home/user
user_pics: /home/user/pics

如何为用户图片使用 user_dir ?如果我必须像这样指定其他属性,它就不会很干燥。

How could I use the user_dir for user_pics? If I have to specify other properties like this, it would not be very DRY.

推荐答案

您可以使用重复的节点,例如

You can use a repeated node, like this:

user_dir: &user_home /home/user
user_pics: *user_home

不过,我认为您无法将其串联起来,因此这不会有效:

I don't think you can concatenate though, so this wouldn't work:

user_dir: &user_home /home/user
user_pics: *user_home/pics

这篇关于如何在YAML中进行字符串连接或字符串替换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆