Search code examples
gruntjsgrunt-contrib-jade

Using lodash (or any other node modules) in Jade with grunt-contrib-jade?


Is it possible to access lodash (or any other node modules) with in a Jade template.

Here is an use case I need to use Is it possible to access lodash (or any other node modules) with in a Jade template.

Here is an use case I need to use

- userNames = _.pluck(users, 'user');
ul
  each name in userNames
  li= name

Solution

  • You could pass Lodash to Jade directly through the data field in options.

    options: {
      data: function(dest, src) {
        return {
          _: require('lodash')
        };
      }
    }