Vorrei usare i baffi per rendere un elenco non ordinato HTML solo se un oggetto elenco non è vuoto. Quindi vorrei:Elenco di rendering dei baffi, se non vuoto
<ul>
<li>item 1</li>
<li>item 2</li>
</ul>
se la lista ha elementi e nulla se la lista è vuota (nemmeno i tag ul)
Come posso fare questo?
edit: la mia struttura dei dati è:
{ "list": ["first item", "second item"] }
Credo che questo sia quello che stai cercando per http://stackoverflow.com/questions/10102931/mustache-templates-how-to-output-a-block-only-once-for-non- empty-lists/10118092 # 10118092 – maxbeatty
Questo è un approccio interessante, ma speravo che ci fosse un modo per farlo senza modificare la mia struttura dati –
Potresti aggiungere la tua struttura dati alla tua domanda? – maxbeatty