Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Feb 23, 2024
Merged

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

merged 3 commits into from
Feb 23, 2024

Conversation

JohnathonKoster
Copy link
Contributor

@JohnathonKoster JohnathonKoster commented Feb 10, 2024

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 JohnathonKoster changed the title [4.x] Antlers: Adds support for shorthand variable binding [4.x] Antlers: Adds shorthand parameter value syntax Feb 10, 2024
@edalzell
Copy link
Contributor

woo hoo!

@benfurfie
Copy link
Contributor

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

@jasonvarga jasonvarga merged commit f569a5f into statamic:4.x Feb 23, 2024
18 checks passed
@jasonvarga jasonvarga deleted the add-shorthand-variable-parameters branch February 23, 2024 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants