Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Mustache: get index of the list element

$
0
0
  1. {{#items}}
  2. // is it possible to get index of rendered element right out of the box? 
  3. {{/items}}

Here is the code of helper I use:
  1. var index = function(expr, options) {      
  2.   var result = []
  3.   expr.forEach(function(e, i){
  4.     result.push(options.fn({index: i, item: e }))
  5.   })  
  6.   return result.join('')        
  7. }

Is this the only solution for the moment? It could be simpler if Observe.List would supported map method.

Viewing all articles
Browse latest Browse all 3491

Latest Images

Trending Articles



Latest Images