We'd like to be able to register and use custom tags and their handlers in our application.yml file to support things such as concatenating scalar value. Example:

base: &base foo
ext1: !concat [*base, '-ext1']
ext2: !concat [*base, '-ext2']

=>

base -> foo
ext1 -> foo-ext1
ext2 -> foo-ext2

Doing such isn't described in the reference guide and a 2-year old SO question about how to do so hasn't been answered so I figured this is an enhancement request. Thanks.

Comment From: wilkinsona

Thanks for the suggestion. You may be able to do this already by registering your own PropertySourceLoader that handles .yml and .yaml files. If it implements Ordered with any precedence higher than lowest precedence, it will be used instead of Boot's YamlPropertySourceLoader. That said, it won't be straightforward to do what you want without losing the capabilities of the package-private OriginTrackedYamlLoader. You could copy-paste this code and modify it to register the Tag and Construct. I'll flag this for discussion at a team meeting to see if we want to offer any extensions points to make this a bit easier.

Comment From: wilkinsona

When evaluating this, we should keep in mind the possibility that we'll want to process .yaml files ahead-of-time as part of optimising native image footprint. We wouldn't want to do anything that would prevent that or make it significantly harder to implement.

Comment From: ctoomey

Turns out the immediate use case we had for this, string concatenating values, is solvable using spring property placeholders, so at this point we don't still have an identified need. In general I do think this would be a useful customization point though.

Alternative solution with property placeholders:

base: foo
ext1: "${base}-ext1"
ext2: "${base}-ext2"

Comment From: philwebb

Given that you've managed to solve this using property placeholders, and we'd like to keep .yaml and .properties features aligned as much as possible, I'm going to close this one. Thanks anyway for the suggestion.