Comments (9)
Sounds complicated to me.
If I recall correctly there has been a similiar issue: #256 Maybe one of the solutions there would help?
from jte.
Ok, thanks for the pointer.
Will take a look next week!
from jte.
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:
<div ${htmx} >
is rendered to this:
this:
<div ${htmx} = "" >
is rendered to
<div hx-get="/helloWorld" hx-swap="outerHTML" =="" ""=""></div>
What do you think?
from jte.
Ugh, that's indeed unexpected!
Problem is, that $unsafe{htmx}
/ ${htmx}
is parsed as attribute name and thus not evaluated by jte.
I've pushed a fix for this, could you have a try if this improves for you with the latest snapshot version?
from jte.
What is the maven Repository URL for snapshots?
I tried https://s01.oss.sonatype.org/content/repositories/snapshots/
but it didn't find it.
from jte.
@tschuehly you can give it a try via jitpack: https://jitpack.io/#casid/jte/-SNAPSHOT
from jte.
@casid
Works with the SNAPSHOT!
from jte.
@tschuehly I'm also interested in creating a helper for htmx
attributes. Do you have an example of what is working for you?
My goal is to make something like this work:
@param hx: HtmxHelper
<div ${hx.get(url="/my/url/"+item.id, swap="outerHTML", target="someId")}>Click me</div>
That would generate:
<div hx-get="/my/url/123" hx-swap="outerHTML" hx-target="someId">Click me</div>
My helper would handle the escaping if $unsafe
were needed.
from jte.
@checketts
Here I have an example of a config that works: tschuehly/htmx-spring-workshop@731c0f3
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:
<button hx-get="${URI(GET_EDIT_USER_MODAL,uuid)}"
hx-target="#${MODAL_CONTAINER_ID}">
<img src="/edit.svg">
</button>
public static final String GET_EDIT_USER_MODAL = "/save-user/modal/{uuid}";
@GetMapping(GET_EDIT_USER_MODAL)
public ViewContext editUserModal(@PathVariable UUID uuid) {
return editUserComponent.render(uuid);
}
For the templates you could create a HTMX object that is then stringified to htmx attributes.
In a Spring specific context I'm thinking of maybe creating a RequestMapping annotation that takes that HTMX object and creates a mapping. This way you still have the easy navigation where it is used.
maybe interesting to you aswell:
HtmxUtil.java
from jte.
Related Issues (20)
- For Loops won't compile for Kotlin HOT 2
- internationalization with MessageFormat HOT 6
- HTML Comments Inside Content Blocks Cause Compilation Failure in gg.jte.gradle v3.1.7+ HOT 2
- Spring Boot integration and binary rendering HOT 6
- ${"\\"} Causes "Unexpected end of template expression" HOT 1
- Pass dynamic HTML Content to template HOT 2
- Support JTE project HOT 2
- Failed to compile with module-info.java HOT 2
- Support for read-only filesystem HOT 1
- template define with generic type HOT 1
- Generic template HOT 3
- Html Template Output HOT 2
- Add kotlin and kte documentation HOT 1
- String input instead of file input HOT 6
- Provide jte-jsp-converter for Jakarta HOT 1
- Comments break JTE HOT 5
- intellij "Cannot resolve MVC view" HOT 4
- Unable to handle model properties that contain dots (`.`) HOT 3
- KTE runtime dependencies HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jte.