src/generator/getCode.js
function registerHandlebarsHelpers() {
  Handlebars.registerHelper('foreach', function(arr, options) {
    if (options.inverse && !arr.length) {
      return options.inverse(this);
    }
    return arr
      .map(function(item, index) {
        item.$index = index;
        item.$first = index === 0;
        item.$last = index === arr.length - 1;
        item.$notFirst = index !== 0;
        item.$notLast = index !== arr.length - 1;
        return options.fn(item);
      })
      .join('');
  });
}
function registerHandlebarsHelpers() {
  Handlebars.registerHelper('foreach', function(arr, options) {
    if (options.inverse && !arr.length) {
      return options.inverse(this);
    }
    return arr
      .map(function(item, index) {
        item.$index = index;
        item.$first = index === 0;
        item.$last = index === arr.length - 1;
        item.$notFirst = index !== 0;
        item.$notLast = index !== arr.length - 1;
        return options.fn(item);
      })
      .join('');
  });
}
function registerHandlebarsHelpers ( ) { Handlebars . registerHelper ( 'foreach' , function ( arr , options ) { if ( options . inverse && ! arr . length ) { return options . inverse ( this ) ; } return arr . map ( function ( item , index ) { item . $index = index ; item . $first = index === 0 ; item . $last = index === arr . length - 1 ; item . $notFirst = index !== 0 ; item . $notLast = index !== arr . length - 1 ; return options . fn ( item ) ; } ) . join ( '' ) ; } ) ; }
registers a helper, which could be used in the templates
@example
{{#foreach}}
{{#if $last}} console.log('this was the last element') {{/if}}
{{#if $notLast}} console.log('this was not the last one') {{/if}}
{{/foreach}}
registers a helper which could be used in the templates