Rakesh Tholiya Rakesh Tholiya - 1 year ago 90
Node.js Question

Node js how to create dynamic path

I want path like "left_sidebar/{user_role}"

{{> layout/left_sidebar/(here_user_role)}}

I have user role in session


So how can i create path like "left_sidebar/admin"

Answer Source

Try with this

var app = express();
app.set('view engine', 'hbs');
app.engine('hbs', exphbs({
    helpers: {
        role_base_partial : function (path,name) {
            return path + name;

In your View file

{{> (role_base_partial 'layout/left_sidebar/' role_name) }}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download