Pregunta

Does anyone know how would you apply an alternating template using JsViews?

For example is there a way to generate markup like this?

<table>
 <thead></thead>
 <tbody>
   <tr class="odd"></tr>
   <tr class="even"></tr>
 </tbody>    
</table>

Thanks!

¿Fue útil?

Solución

Within a template, the index is available using #index

There is an {{if}} construct that can be used to alternate between two choices.

The untested code would be something like:

{{if #index % 2 }}
    code for odd case
{{else}}
    code for even case
{{/if}}

Do a view source of this to see a simple use of #index.

Do a view source of this to see a simple use of if, then, else.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top