Open gkmcd opened 2 years ago
I think it is using an older (or different) version of handlebars. Kinda hard to keep the APIs straight. :expressionless:
What is next here? Document the correct Handlebars version to use? Merge the above fix?
Ended up with exactly the same issue...
I'm also dealing with this issue. Is there a previous version of handllebars that works with htmx ? Been trying but so far didn't get any output.
<script src="https://unpkg.com/htmx.org"></script>
<script src="https://unpkg.com/htmx.org/dist/ext/client-side-templates.js"></script>
<script src="https://unpkg.com/handlebars@latest/dist/handlebars.min.js"></script>
<table
class="container"
hx-ext="client-side-templates"
hx-get="https://jsonplaceholder.typicode.com/users?_limit=5"
hx-swap="innerHTML"
hx-target="tbody"
hx-trigger="load"
handlebars-array-template="foo"
>
<thead>
<th>Name</th>
<th>Email</th>
</thead>
<tbody></tbody>
</table>
<template id="foo">
{{#each this}}
<tr>
<td>{{name}}</td>
<td>{{email}}</td>
</tr>
{{/each}}
</template>
Handlebars templates don't seem to work with the client-side-templates extension.
TypeError: Handlebars.partials[templateName] is not a function
There appears to be a number of steps missing to properly create a handlebars partial. I've modified the handlebars section of the client-side-extensions script to achieve working Handlebars templates:
Caution: I am not a JS dev.