cms icon indicating copy to clipboard operation
cms copied to clipboard

[4.x] Antlers: Adds shorthand parameter value syntax

Open JohnathonKoster opened this issue 1 year ago • 2 comments

This PR introduces a new shorthand variable binding syntax for Antlers parameters. This syntax can be used to simplify passing variables into tags when the parameter and variable have the same name.

This:

{{ some_tag_name :class="class" }}

Can now be simplified to:

{{ some_tag_name :$class }}

The parser will internally expand this to the longer form and continue as normal. This syntax can be mixed with normal parameters:

{{ some_tag param="value" :$class param_two="value_two" }}

The following examples are not valid and the parser will throw errors:

{{ tag_name :$thing="some_value" }}
{{ tag_name :$1234value }}
{{ tag_name :$ }}
{{ tag_name :$}}

JohnathonKoster avatar Feb 10 '24 19:02 JohnathonKoster

woo hoo!

edalzell avatar Feb 10 '24 20:02 edalzell

Love this @JohnathonKoster. This will save so much unnecessary code.

benfurfie avatar Feb 11 '24 12:02 benfurfie