bigskysoftware / bigskysoftware/htmx
templating overwrites "this" in <td> tag
- Dominant language
- JavaScript
- Stars
- 49.4k
- Forks
- 1.7k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 30
Description
I thought this was a handlebars error but this fiddle works fine: https://jsfiddle.net/onzew2s1/1/
Fiddle code:
```
Handlebars.registerHelper('stringify', function(arg1) {
return JSON.stringify(arg1);
});
global this: {{stringify this}} <br/>
table start <br/>
<table id="tiles">
<tbody>
{{#each tiles}}
<tr>
{{#each this}}
outside of td: {{stringify this}} <br/>
<td>
td: {{stringify this}}
</td>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
table done
```
It has this output:
```
global this: {"tiles":[["a","b"],["c","d"]]}
table start
outside of td: "a"
outside of td: "b"
outside of td: "c"
outside of td: "d"
td: "a" td: "b"
td: "c" td: "d"
table done
```
In contrast, my htmx code with the same input (shown to be identical with `stringify`):
```
Handlebars.registerHelper('stringify', function(arg1) {
return JSON.stringify(arg1);
});
global this: {{stringify this}}
table start
{{#each tiles}}
{{#each this}}
outside of td: {{stringify this}}
{{/each}}
{{/each}}
td: {{stringify this}}
table done
```
has this output:
```
global this: {"tiles":[["a","b"],["c","d"]]}
table start
outside of td: "a"
outside of td: "b"
outside of td: "c"
outside of td: "d"
td: {"tiles":[["a","b"],["c","d"]]}
table done
```
Contributor guide
Assessment
This issue has not been assessed yet.