bigskysoftware / htmx

</> htmx - high power tools for HTML
https://htmx.org
Other
38.56k stars 1.31k forks source link

HTMX 2.0.3 with client-side-templates and Mustache not working #3004

Closed PetrVobornik closed 2 weeks ago

PetrVobornik commented 2 weeks ago

Combination HTMX last version 2.0.3 + extension client-side-templates 2.0.3 with Mustache not working as in previows version 1.9.12.

<!-- Version 1.9.12 - WORKS FINE -->
<script src="https://unpkg.com/htmx.org@1.9.12"></script>
<script src="https://unpkg.com/htmx.org@1.9.12/dist/ext/client-side-templates.js"></script>
<script src="https://unpkg.com/mustache@latest"></script>

<!-- Version 2.0.3 - NOT WORKING -->
<script src="https://unpkg.com/htmx.org@2.0.3"></script>
<script src="https://unpkg.com/htmx.org@2.0.3/dist/ext/client-side-templates.js"></script>
<script src="https://unpkg.com/mustache@latest"></script>

Here I have prepared a sample of two pages that differ only in the version of HTMX used: https://playcode.io/2129377?v=2

MichaelWest22 commented 2 weeks ago

https://htmx.org/migration-guide-htmx-1/ https://github.com/bigskysoftware/htmx-extensions/blob/main/src/client-side-templates/README.md

When upgrading from htmx v1 to v2 there are some changes that were implemented so you may need to be aware of them. Biggest change impacting you is that now by default htmx v2 does not allow unsafe requests to external urls. There is a note about this also at the bottom of the client side templates extension documentation as well.

PetrVobornik commented 2 weeks ago

Thank you and I'm sorry, I didn't notice that. Adding this meta tag solved the problem and everything works as before.

<meta name="htmx-config" content='{"selfRequestsOnly":false}'>