title: How can i return the value using node with express in app.locals function
body: <p>I am working on nodejs express and implement app.locals function</p>
  
  <p>in view(ejs templete) file:-</p>
  
  <pre><code>&lt;% if(someHelper('/admin/dashboard',req.user._id)){ %&gt;
          &lt;li&gt;
              &lt;a href="/admin/dashboard"&gt;
                  &lt;i class="fa fa-user"&gt;
                  &lt;/i&gt;
                  &lt;span&gt;
                      Create Chairman
                  &lt;/span&gt;
              &lt;/a&gt;
          &lt;/li&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>in app.js(server.js) file:-</p>
  
  <pre><code>app.locals.someHelper = function(route_name,user_id) {
  
  user.find({user_id:user_id, route_name:route_name}, function(err, user_per){
  if(err) return false;
      if(typeof user_per != 'undefined' &amp;&amp; user_per.length &gt; 0){
              return true;
              console.log("true");
      } else {
          return false;
          console.log("false");
      }
  });
  }
  </code></pre>
  
  <p>when if condition is executed then not return permitted value 1.</p>
  
  <p>also tried for take req and callback perameter and return the value but both are not useful in this  function.</p>
  
  <pre><code>app.locals.someHelper = function(route_name, user_id, callback) {
  user.find({ 
      user_id: user_id,
      route_name: route_name
  }, function(err, user_per) {
  
      if(typeof user_per != 'undefined' &amp;&amp; user_per.length &gt; 0){
          // permitted
          return callback(1);
      }
  
      callback(0);
  });
  }
  </code></pre>
  
  <blockquote>
    <p>callback is not a function</p>
  </blockquote>
  
  <p>i want return permitted 0 if portion is not executed else return permitted 1.</p>
  
  <p><a href="https://stackoverflow.com/questions/13221760/nodejs-ejs-helper-functions?answertab=votes#tab-top">reference</a></p>