File tree Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 11# lodash-template-loader
22Lodash template loader for Webpack.
33
4- This is tiny webpack loader which wraps lodash ` _.template() ` to render templates during webpack build.
4+ This is tiny webpack loader which wraps lodash ` _.template() ` to render templates during webpack build.
5+ This loader outputs fully rendered string (HTML) without bundling lodash.
56Global data for templates (views) is passed using ` imports ` property of loader options object.
67
78Other available options:
@@ -12,7 +13,7 @@ Other available options:
1213### Install
1314
1415``` sh
15- $ npm i lodash-template-loader --save
16+ $ npm i lodash-simple- template-loader --save
1617```
1718
1819### Usage
@@ -27,7 +28,7 @@ module: {
2728 loader: ' apply-loader'
2829 },
2930 {
30- loader: ' lodash-template-loader' ,
31+ loader: ' lodash-simple- template-loader' ,
3132 options: {
3233 imports: { // data object which will be passed to templates for rendering
3334 title: ' Hello World!'
Original file line number Diff line number Diff line change @@ -6,18 +6,18 @@ const loaderUtils = require('loader-utils');
66module . exports = function ( source ) {
77 const options = loaderUtils . getOptions ( this ) || { } ;
88
9- if ( _ . isRegExp ( _ . templateSettings . escape ) ) {
9+ _ . templateSettings . imports = _ . isObject ( options . imports ) ? options . imports : { } ;
10+ _ . templateSettings . imports . _ = _ ;
11+
12+ if ( _ . isRegExp ( options . escape ) ) {
1013 _ . templateSettings . escape = options . escape ;
1114 }
12- if ( _ . isRegExp ( _ . templateSettings . evaluate ) ) {
15+ if ( _ . isRegExp ( options . evaluate ) ) {
1316 _ . templateSettings . evaluate = options . evaluate ;
1417 }
15- if ( _ . isRegExp ( _ . templateSettings . interpolate ) ) {
18+ if ( _ . isRegExp ( options . interpolate ) ) {
1619 _ . templateSettings . interpolate = options . interpolate ;
1720 }
18- if ( _ . isObject ( options . imports ) ) {
19- _ . templateSettings . imports = options . imports ;
20- }
2121
2222 const compiled = _ . template ( source ) ;
2323 const renderedView = compiled ( ) ;
Original file line number Diff line number Diff line change 11{
22 "name" : " lodash-simple-template-loader" ,
3- "version" : " 1.1 .0" ,
3+ "version" : " 1.2 .0" ,
44 "description" : " Lodash template loader for Webpack" ,
55 "main" : " index.js" ,
66 "scripts" : {
You can’t perform that action at this time.
0 commit comments