yaml / yaml-spec

YAML Specification
http://yaml.org/spec/
348 stars 54 forks source link

Feature request: string interpolation #297

Open shawalli opened 1 year ago

shawalli commented 1 year ago

Many languages support some form of string interpolation. Adding string interpolation to YAML would enhance anchors/aliases. Below is a contrived example. Obviously the interpolation markers may not work, but this is just to give an idea.

user: &user john

cname: "{{ *user }}.somesite.com"
host: "{{ *user }}.ec2.somecompany"
shared-dir: "/some/shared/path/{{ *host }}"

In this example, user is interpolated into cname and hostname, andhost is interpolated into shared-dir, resulting in:

user: john

cname: "john.somesite.com"
host: "john.ec2.somecompany"
shared-dir: "/some/shared/path/john.ec2.somecompany"

Not sure if this is the right place to request new features for the spec, so let me know if I should post elsewhere.