fenekku / moustachu

Mustache templating for Nim
65 stars 8 forks source link

bug: empty seq with last markup #13

Closed JohnAD closed 5 years ago

JohnAD commented 6 years ago

If the last item (token?) in a template is for a sequence,

{{# something}}
{{{.}}}
{{/ something}}

But that sequence is empty, then an "IndexError" is generated in ignore.

Both conditions have to be true for this to happen. For now, a workaround is simply adding a new empty token at the end. For example:

{{# something}}
{{{.}}}
{{/ something}}
{{ empty_text }}

For reference, the error message (as seen from my PR branch):

moustachu.nim(203)       render
moustachu.nim(114)       render
moustachu.nim(55)        ignore
system.nim(2833)         sysFatal
Error: unhandled exception: index out of bounds [IndexError]

A fix is already in my PR. As soon as I finish up documentation, I'll request a review.

fenekku commented 6 years ago

12 should fix this!

fenekku commented 5 years ago

12 merged. I am closing this.