Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Dynamic sidebars with Node.js, Express.js and Jade

Dynamic sidebars with Node.js, Express.js and Jade


I'm trying to write a dynamicHelper for Jade to check if a user is allowed to access a resource before actually accessing it. I have the module to perform the checks which returns true or false when called with the url and username of the resource to be accessed, but I can't get the helper working with parameters?

dummy view:

if(hasAccess.check("/url", "username") == true)
  li access
  li no-access


  hasAccess: function() {
    return access;


var access = function() {
  return {
    check: function(url, user) {
      return mymodule.hasAccess(url, user);

I tried to get it done with this answer, but no luck so far.

Problem courtesy of: Patrick


There are a couple of things wrong there (if I understand it correctly)

  • Your hasAccess function isn't accepting any parameters
  • hasAccess is also just returning a reference to the access function, not calling it
  • the access function doesn't accept any parameters either

It's possible that what you're trying to do would work using

  hasAccess: access().check

But i haven't run the code, so I may be completely wrong.

Good luck :)

Solution courtesy of: arnorhs


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Dynamic sidebars with Node.js, Express.js and Jade


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription