-
Notifications
You must be signed in to change notification settings - Fork 62
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
Allow expressions in HTML attribute names for certain types #326
Comments
Sounds complicated to me. If I recall correctly there has been a similiar issue: #256 Maybe one of the solutions there would help? |
Ok, thanks for the pointer. |
Hey @casid. Finally got some time to try it out. I tried it out both with $unsafe and the custom Policy, but it does not behave like I would expect it public static final String htmx = "hx-get=/helloWorld hx-swap=outerHTML"; This HTML: this: What do you think? |
Ugh, that's indeed unexpected! Problem is, that I've pushed a fix for this, could you have a try if this improves for you with the latest snapshot version? |
What is the maven Repository URL for snapshots? |
@tschuehly you can give it a try via jitpack: https://jitpack.io/#casid/jte/-SNAPSHOT |
@casid |
@tschuehly I'm also interested in creating a helper for My goal is to make something like this work:
That would generate:
My helper would handle the escaping if |
@checketts I'm not really sure how to approach this the best. I really come to like using static public final variables to make it easy to see what controller endpoint htmx is calling:
For the templates you could create a HTMX object that is then stringified to htmx attributes. maybe interesting to you aswell: |
Currently If I put an expression in the html next to an attribute:
I get this error
Illegal HTML attribute name ${action}! Expressions in HTML attribute names are not allowed.
In our use case we have a record that represents HTMX attributes:
public record HTMXAction(String path, String target, Type type, Swap swa)
According to this it is for html sanitation -> #300 (comment)
I think there are several ways to implement this while still allowing sanitation .
One way would be to have a certain type similar to
Content
that would allow for expressions in attributes.What do you think about this idea?
It would allow to have much cleaner html templates
The text was updated successfully, but these errors were encountered: