0.3.0 • Published 7 years ago

underscore-template-strict-loader v0.3.0

Weekly downloads
366
License
MIT
Repository
github
Last release
7 years ago

underscore-template-strict-loader

CircleCI License npm

An Underscore.js template loader for Webpack that works with strict mode. Underscore templates don't work with strict mode by default because they use the with(data) function to give you access to your data variables. This plugin works by prefixing each variable in your templates with data.whatever so {{ name }} becomes {{ data.name }}.

Installation

Once you have the Underscore package installed, you can run:

npm install underscore-template-strict-loader

License

underscore-template-strict-loader is MIT licenced.

Usage

module.exports = {
    module: {
            test: /\.jst/,
            loader: 'underscore-template-strict-loader',
            query: {
                templateSettings: {
                    evaluate: /\{\[([\s\S]+?)\]\}/,
                    escape: /\{\{([\s\S]+?)\}\}/,
                    interpolate: /\{\!([\s\S]+?)\!\}/
                },
                
                // use dataObjName option to define the name of the data object
                // for templates. It's "data" by default.
                dataObjName: 'templateData',

                // use the globals option to define variables that
                // should not be prefixed
                globals: ['$', 'jQuery'],

                // Add this only if you want to prefix the template with
                // an HTML comment with the path to the file for debugging.
                addFilenameComment: true
            }
        }
};

Other

This is being used in Beta at SpyFu

0.3.0

7 years ago

0.2.0

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

1.0.0

7 years ago