title: NodeJS /Express/ ExpressHandlebars - global helper functions
body: <p>I can promise you the I have yelled at my monitors by now and spend hours upon hours to understand this. 
   First off, I can't understand the concept of having a templating engine like handlebars that cant do simple comparison functions. </p>
  
  <p>In any case. I have this helper function that works great when added to the individual route as you can see here. However I would really like to add it as a global function in my <strong>app.js</strong> file created by express. I can promise you that the GITHub example of the helper function does not work. </p>
  
  <p>Any help will really be appreciated. </p>
  
  <p>my index.js files. </p>
  
  <pre><code>/* GET home page. */
   router.get('/', function(req, res, next) {
   Coupon.find(function(err, docs)
   {
  
    res.render('main/index', { 
  
      title: 'Coupon Site new for all', 
      coupons: docs,
  
      //helpers
       helpers: {
           eq: function (v1, v2) {
               return v1 === v2;
           },
           ne: function (v1, v2) {
               return v1 !== v2;
           },
           lt: function (v1, v2) {
               return v1 &lt; v2;
           },
           gt: function (v1, v2) {
               return v1 &gt; v2;
           },
           lte: function (v1, v2) {
               return v1 &lt;= v2;
           },
           gte: function (v1, v2) {
               return v1 &gt;= v2;
           },
           and: function (v1, v2) {
               return v1 &amp;&amp; v2;
           },
           or: function (v1, v2) {
               return v1 || v2;
           }
         },
       });   
  
     });
  
  });
  </code></pre>
  
  <p>And in the app.js apparently I should be able to do something like this. What is not in the documentation, I figure that I should somehow import the <code>hbs</code> variable in my <strong>index.js</strong></p>
  
  <pre><code>var hbs = exphbs.create({
      // Specify helpers which are only registered on this instance.
      helpers: {
         foo: function () { return 'FOO!'; },
      bar: function () { return 'BAR!'; }
    }
   });
  </code></pre>