1.0.0 • Published 5 years ago

babel-plugin-lodash-template-compile v1.0.0

Weekly downloads
56
License
MIT
Repository
github
Last release
5 years ago

Babel Plugin Lodash Template Compile

Babel plugin for compiling lodash templates at compile-time, rather than run-time.

Install

npm install --save-dev babel-plugin-lodash-template-compile

Usage

Add this plugin to your babel plugins:

  plugins: [
    ['babel-plugin-lodash-template-compile', { /* plugin options */ }]
  ]

This plugin supports the following options:

{
  minify?: boolean, // Whether to minify the compiled template or not
  data?: any, // If provided the templates will be rendered to HTML directly using this data
  templateOptions?: {} // All options supported by `lodash.template`
}

This plugin will compile lodash templates written like so at compile-time, so that your app won't waste time on this at run-time:

_.template ( '<%= obj.value %>' );
_.template ( "<%= obj.value %>" );
_.template ( `<%= obj.value %>` );
lodash.template ( '<%= obj.value %>' );
lodash.template ( "<%= obj.value %>" );
lodash.template ( `<%= obj.value %>` );

Other ways to use lodash's template function aren't currently supported.

License

MIT © Fabio Spampinato