Closed johntom closed 1 year ago
I just posted below yesterday on discord in htmx-general my workaround for this issue. codepen link https://codepen.io/johntom/pen/bGQNBXB
Hi, no need to explain sending html from server as the best way for htmx as this was an exercise to figure out why client-side-extentions worked in codepen and failed on node server using fastify/nunjucks as backend. In my codepen https://codepen.io/johntom/pen/bGQNBXB button 1. Handle with nunjucks works as expected. button 2. Handle with nunjucks nodeserver only works works on nodeserver when I assign template in the js code provided in code pen. If I don't assign template.innerHTML nothing shows up. Commenting the assignment out of js code and you will see button1 work as expected. Any ideas on how to get the template to run without this modification?
passing the script in view also works.
const search= {% for res in results %} title:{{res.title}}<br> body:{{res.body}}<br><hr>{% endfor %}
return reply.view('CSNunjucks.njk', { title: 'CSNunjucks htmx features njk' , search:search});
Hi, 1) If I load CSN.Html with live server the following example works as expected. 2) If I load page with fastify server using nunjucls the script tag does not get processed 3) Is there a way to process script tags when using nunjucks from a node server? TIA John
1 CSN.Html
scriptall.js
2
1 change in scriptall.js when processing from node-fastify server
the script is empty