tera
tera copied to clipboard
Support for maps in the template language
As far as I can tell, you can create arrays in a template, but not a map. It'd be useful to have map support, so you can create maps and use map literals. There's already support for working with maps provided in the context (eg. get).
Is this a feasible request or is there something inherently problematic with it?
Thanks for considering!
It is feasible, just not on my roadmap as it is pretty niche imo
I could implement this using filters. Since you can already create arrays, you could use a filter to extend it like this:
{% set x = [] | setmap(attribute="a", value="b") %}
It would work like a setter counterpart for map. Does that sound good @Keats?
Ideally I would prefer having map creation be a built-in feature but that requires quite a lot of changes to the parser and I'm not too confident in pest right now to add more to it.