casid / jte

Secure and speedy templates for Java and Kotlin.
https://jte.gg
Apache License 2.0
844 stars 63 forks source link

Comments break JTE #359

Closed tschuehly closed 6 months ago

tschuehly commented 6 months ago

Hello @casid , I'm using JTE in my server-side rendering with Spring workshop: https://tschuehly.gitbook.io/server-side-spring-htmx-workshop/lab-3-inline-editing

To explain the code snippets I added JTE comments with <%-- (1) --%> to the code.

@import static de.tschuehly.easy.spring.auth.group.GroupController.*
@param de.tschuehly.easy.spring.auth.group.management.table.user.AddUserComponent.AddUserContext addUserContext
<form hx-post="${HtmxUtil.URI(POST_ADD_USER,addUserContext.groupName())}" <%-- (1) --%>
      hx-target="${HtmxUtil.target(GroupTableComponent.GROUP_TABLE_ID)}" <%-- (2) --%>
      hx-swap="outerHTML"> <%-- (2) --%>
    <select>
        @for(var easyUser: addUserContext.easyUserList()) <%-- (3) --%>
            <option value="${easyUser.uuid.toString()}">
                ${easyUser.username}
            </option>
        @endfor
    </select>
    <button type="submit">Add User to group</button>
</form>

This breaks JTE rendering, it will still render but the attributes after the first comment are not part of the tag anymore.

If I instead use normal HTML comments <-- --> in the same place, JTE will render it correctly but the syntax highlighting of the JTE plugin will break.

I would expect that the JTE comments are completely ignored from rendering.

It would be lovely if you could provide a hotfix as I'm repeating the workshop two times in the next two weeks.

Thank you!

casid commented 6 months ago

Thank you for reporting @tschuehly and thanks for sharing your workshop. That is pretty cool!

I think this issue should be fixed now. Would you be able to try if it works with all your workshop examples as well? You should be able to test with the latest snapshot release:

https://jitpack.io/#casid/jte/-SNAPSHOT

Once you confirm the fix, I will create a new bugfix release.

tschuehly commented 6 months ago

Thank you for the quick fix! I can try it out next week.

tschuehly commented 6 months ago

Hey @casid I finally had time to test it. The fix works! Would be awesome if you could create a bugfix release.

Jitpack seems to have a problem building the runtime: https://jitpack.io/com/github/casid/jte/3ad76aa95f/build.log But I've built locally

casid commented 6 months ago

Hi @tschuehly,

thank you for testing and confirming the fix!

I will release a new version today.

Jitpack seems to have a problem building the runtime

It looks like Jitpack still uses Java 8 for building and the --release option is not available there yet.

Cheers!

casid commented 6 months ago

jte 3.1.12 is now published, containing this fix.