-
Notifications
You must be signed in to change notification settings - Fork 69
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
Conditional Attributes #380
Comments
If the attribute value is null, it will be omitted, hope that helps. |
Yes I know that but I would need to put the if else in a ternary operator which is uglier imo. @casid If you think this is ok/possible I could take a crack at changing the behaviour. Or is there a certain reason why the behaviour is as it is? |
@tschuehly this is because jte by default only allows writing into safe slots of a template. The parser expects to find an attribute name within this div. This needs to be done in order to decide how to escape the attribute content, which is a safe slot to write to. Having logical expressions in here would let the complexity of the parser explode, and also make it impossible to guarantee properly escaped templates. |
Is there a way to extend the parser? So I could write a plugin where I could implement that behaviour? |
No there is not. The parser is already quite complex and I fear opening this rabbit hole would make everything a lot harder to maintain, while the benefit to it is rather low. The risk on the other hand quite high, to accidentially introduce unsafe behavior or break user code. |
How about using a special constant
|
This constant already exists: null |
Currently I cannot use a
@if
conditional around a html attributeI get the following exception:
I really would like to do that as I don't necessarily want to put my alpine.js code into my java code and instead put it into my template.
The text was updated successfully, but these errors were encountered: