title: What is the options parameter in a Handlebars helper function?
body: <p>I am creating a custom handlebar helper but it always throws <code>Object #&lt;Object&gt; has no method 'fn'</code> when compiled through the terminal. </p>
  
  <p>My handlebar helper is:</p>
  
  <pre><code>module.exports.register = function (Handlebars, opts, params)  { 
      Handlebars.registerHelper('compimg', function (context, opts)  { 
          var compImg = ["assets/img/icon-nope.png","assets/img/icon-check.png"];
          return compImg[opts.fn(context)];
      });
  }
  </code></pre>
  
  <p>My .hbs file is:</p>
  
  <pre><code>{{#each checkable}}
     &lt;div class="col-md-3 col-xs-3 icon-container"&gt;&lt;img src="{{compimg this}}"&gt;&lt;/div&gt;
  {{/each}}
  </code></pre>
  
  <p>My JSON file is:</p>
  
  <pre><code>{
      "desc": "blablabla",
      "checkable": [
          1,
          1,
          1,
          1
      ]
  }
  </code></pre>
  
  <p>When I checked the official documentation I found this piece of code. Can someone explain what exactly <code>context</code> and <code>options</code> are here?</p>
  
  <pre><code>Handlebars.registerHelper('each', function(context, options) {
    var ret = "";
  
    for(var i=0, j=context.length; i&lt;j; i++) {
      ret = ret + options.fn(context[i]);
    }
  
    return ret;
  });
  </code></pre>