I am attempting to use node-underscorify with Grunt to compile HTML templates into a format that Underscore will accept.
My gruntfile looks as such:
browserify: {
standalone: {
src: ['<%= config.main %>/*/*.js'],
dest: '<%= config.dist %>/js/<%= pkg.name %>.standalone.js',
options: {
standalone: '<%= pkg.name %>',
transform: ['node-underscorify'],
debug: true,
external: ['jquery', 'underscore', 'backbone.marionette']
}
},
All was working well until I tried to use Underscore methods inside HTML templates. For example, trying to call _.each results in a " _ is not defined" error. According to the node-underscorify documentation, an require option can be passed in, such as:
requires:[{variable: '_', module: 'underscore'}]}
How can I properly set up node-underscorify to work with Grunt such that I can use underscore methods in my HTML templates (or view helpers, etc)?