Choose from YAML arrays by changing single YAML variable

Given some example yaml frontmatter:

choice: this
this:
  color: blue
that:
  color: red

I can place {{ this.color }} resulting in “blue” within a template, but would like to access the color by using something akin to {{ choice.color }}. This way, I can change one item (choice) and have that single change feed a different array of name/values.

Hello there Alice! I like your avatar :wink:

Well, you could just leave out the choice bit and simply write {{ this.color }} or {{ that.color }}, depending on your choice. But I think you probably have a reason for putting it in – maybe you can explain a little more what you are trying to do? There may well be another solution.

Hi Netzhexe and thanks!

I’m really trying to get much more swapped out than the example given, and just realized ‘frontmatter’ may have been the wrong word choice for a config file. The this and that arrays would have much more included. I would like to have a config file user/config/data-sets.yaml or similar with sets of data that may be switched out site-wide with one variable change pointing toward an array.

This way, I could have {{ config:data-set:choice:color }} and {{ config:data-set:choice:address }} and {{ config:data-set:choice:item-number }} on many pages throughout the site then switch them all out by changing one variable in the config file.

I’ve tried a few things that sounded promising from reading the documentation for Grav and TWIG such as {{ config:data-set."#{config:data-set:choice}".color }} and even {% set params = config:data-set:choice %} then {{ config:data-set:params:color }}.

Essentially, I’d like to know if there is some existing functionality that enables a set of shortcodes used site-wide to switch between YAML data sets in Grav/TWIG.