Search code examples
concatenationyaml

How can I do string concatenation, or string replacement in YAML?


I have this:

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

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.


Solution

  • 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