title: handlebars.js template with custom helper to slice data array
body: <p>im trying to set up a handlebars template using a custom helper but i can't seem to get it to work. The block helper should be able to slice my data array like it says <a href="https://github.com/raDiesle/Handlebars.js-helpers-collection#IterateSliced" rel="nofollow">here</a>.</p>
  
  <p>When i call every index in my array without using the helper my template it works properly. </p>
  
  <p>This is my template </p>
  
  <pre><code>          &lt;script id="template_marcas" type="text/x-handlebars-template"&gt;
            {{#datos_marcas}}
              &lt;div class="large-3 small-3 columns marca_item"&gt;
                &lt;div class="marca_content"&gt;
                  &lt;h3&gt;{{img}}&lt;/h3&gt;
                  &lt;p&gt;{{descp}}&lt;/p&gt;
                  &lt;a href="{{href}}"&gt;Ver descuentos&lt;/a&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            {{/datos_marcas}}
            &lt;/script&gt;
  </code></pre>
  
  <p>My data array:</p>
  
  <pre><code>var data_marcas = { 
    datos_marcas: [
        {
          "img":"alverto",
          "descp":"Descripción Marta",
          "href":"test"
        },
         {
          "img":"marta",
          "descp":"Descripción Marca",
          "href":"test"
        },
         {
          "img":"marca",
          "descp":"Descripción Marca",
          "href":"test"
        } //etc.....
      ]
    };
  </code></pre>
  
  <p>And this is the helper i'm trying to use </p>
  
  <pre><code>Handlebars.registerHelper('slice', function(context, block) {
  var ret = "",
    offset = parseInt(block.hash.offset) || 0,
    limit = parseInt(block.hash.limit) || 5,
    i = (offset &lt; context.length) ? offset : 0,
    j = ((limit + offset) &lt; context.length) ? (limit + offset) : context.length;
  
  for(i,j; i&lt;j; i++) {
    ret += block(context[i]);
  }
  
    return ret;
  });
  </code></pre>
  
  <p>which i found <a href="https://github.com/raDiesle/Handlebars.js-helpers-collection#first" rel="nofollow">here</a></p>
  
  <p>EDIT</p>
  
  <p>I'm trying to use the helper as below, perhaps there is something wrong with the way i'm calling it.</p>
  
  <pre><code>          &lt;script id="template_marcas" type="text/x-handlebars-template"&gt;
            {{#slice datos_marcas offset="1" limit="5"}}
              &lt;div class="large-3 small-3 columns marca_item"&gt;
                &lt;div class="marca_content"&gt;
                  &lt;h3&gt;{{img}}&lt;/h3&gt;
                  &lt;p&gt;{{descp}}&lt;/p&gt;
                  &lt;a href="{{href}}"&gt;Ver descuentos&lt;/a&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            {{/slice}}
            &lt;/script&gt;
  </code></pre>