Skip to content

Latest commit

 

History

History
41 lines (35 loc) · 1.07 KB

File metadata and controls

41 lines (35 loc) · 1.07 KB

lodash-template-loader

Lodash template loader for Webpack.

This is tiny webpack loader which wraps lodash _.template() to render templates during webpack build. This loader outputs fully rendered string (HTML) without bundling lodash. Global data for templates (views) is passed using imports property of loader options object.

Other available options:

  • [options.escape] (RegExp): The HTML "escape" delimiter.
  • [options.evaluate] (RegExp): The "evaluate" delimiter.
  • [options.interpolate] (RegExp): The "interpolate" delimiter.

Install

$ npm i lodash-simple-template-loader --save

Usage

WebPack 2.x

module: {
    rules: [ {
        test: /\.html$/,
        use: [
            {
                loader: 'apply-loader'
            },
            {
                loader: 'lodash-simple-template-loader',
                options: {
                    imports: { // data object which will be passed to templates for rendering
                        title: 'Hello World!'
                    }
                }
            }
        ]
    } ]
}