Tuesday 11 April 2017

Check if key exists in array in nunjucks template (Node JS)

I am creating an application in Node Js using Nunjucks template engine and I have to apply permissions on pages to show add, edit and delete links.

For this I have implemented an array of permissions like below :

var user_params = ['add_user', 'edit_user', 'delete_user'];

Now I want to check on pages that add_user exists in user_params array or not just like we do in php

in_array('add_user', user_params)

But I am being able to perform this task in nunjucks. So can anyone help me out ?

Thanks in advance



via Ankit

No comments:

Post a Comment