-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
[5.x] Antlers: Adds support for disabling Antlers entirely inside tag parameter content #8887
[5.x] Antlers: Adds support for disabling Antlers entirely inside tag parameter content #8887
Conversation
Just thinking out loud, but if you needed the output of backend variables in the JS, would something like this work? {{? $js = '{ open: '.$variable.', toggle() { this.open = ! this.open } }' ?}}
{{ form:contact :\x-data="js" }}
...
{{ /form:contact }} |
For that, you could accomplish that without this PR and just do I could likely get something similar to the following working without a ton of additional effort, but would need to gauge utility/interest (potentially feedback from Core on whether to continue with it): {{ form:contact \x-data="{ open: ${open | bool_string}, toggle() { this.open = ! this.open } }" }}
...
{{ /form:contact }} Would introduce some new syntax rules when using
There would be a number of things to consider when adding support for this:
{{ some:thing \escaped="This {is} {all} escaped ${another:tag \param="nested ${fun:stuff \here="{we} ${go}"}"}" }} Not directly related to the functionality of the runtime itself:
|
Adding another symbol is a bit confusing IMO. "Use a I would personally prefer That would make it a breaking change, so we could just have this target 5.x. Along with making attributes on form-rendering tags (like So, as part of the upgrade guide, you'd need to do this on your form tags: {{ form:create
in="contact"
redirect="/thanks"
- class="foo"
- @submit="submitForm"
+ attr:class="foo"
+ attr:@submit="submitForm"
}} As for this:
Let's just stick with escaping the whole parameter content for now. This sounds super complicated. 😄 |
I concur with @jasonvarga. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please target master
, and just change the prefix to @
.
We can tackle the form attr:
prefix changes in a separate PR.
Done. Changed the PR target to master and applied the requested changes. Let me know if you need anything else on this. |
This adjusts a previous test to account for this change
I just updated |
Done! |
# Conflicts: # tests/Antlers/Parser/NodeParametersTest.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey John, this is great.
But after merging master
back into this, there's a failing test. I'm not sure where it was introduced. I don't think it's this PR though, but maybe you can figure it out?
There's also one deprecation warning - don't worry about that for now.
You're right, it was in that merge. My fault. Must have been my editor automatically stripping trailing spaces when I saved for that merge conflict, and I didn't notice. Thanks. |
This PR adds support for disabling the parsing of Antlers entirely when supplying parameter values by introducing new syntax.
For example, let us consider the following form tag using the existing syntax to escape
{
and}
safely inside parameter content:With the changes in this PR, we could now just prefix our parameter name with a single backslash (
\
) character:Notes/considerations:
\
syntax. This syntax completely disables the recursive parserBreaking change concerns: none. The\parameter="something"
is currently illegal syntax, and won't produce parameters at allWhy not use@parameter="something"
to indicate the escaped content? While this would be nice for consistency, it would be a breaking change since using parameters like@click="doTheRoar()"
is already supported