You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thank you for stache. I am starting to use it for a project of mines. It is the first implementation of Mustache that I use, so please pardon me if this looks uninteresting.
Overall mustache is okay for templating. However, I am constantly facing an issue when I need to render lists of items. The pattern is always the same :
when the list is not empty
insert list title
open list tag
loop over list items
close list tag
when the list is empty, render nothing
It seems that this very basic task can't be done with bare Mustache, since the following code
{{# list }}
<h1> Here is the list </h1>
<ul>
<li> {{ item }} </li>
</ul>
{{/ list }}
Hi,
thank you for stache. I am starting to use it for a project of mines. It is the first implementation of Mustache that I use, so please pardon me if this looks uninteresting.
Overall mustache is okay for templating. However, I am constantly facing an issue when I need to render lists of items. The pattern is always the same :
It seems that this very basic task can't be done with bare Mustache, since the following code
would include everything in the loop.
This general issue is described here as well https://stackoverflow.com/questions/13074252/mustache-render-list-if-not-empty/19427241
Various implementations offer some enhancements to ease this common task. Is there something in stache for this situation ?
In my opinion, the issue arises from Mustache confusion of "existence test" and "loop over". Mixing the two brings this sort of issues.
I would propose a syntax extension in the form of
{{#? var }} has only one semantic : render the bloc if 'var' value is a non-empty list.
What do you think ?
Regards,
The text was updated successfully, but these errors were encountered: