From d6b65dd1531038deac1be87c2087da5955903d24 Mon Sep 17 00:00:00 2001 From: Tommy Troy Lin Date: Thu, 17 May 2018 10:22:00 +0800 Subject: [PATCH] feat: support ES6 template string in default loader Only transpile EJS style `<%= name %>`, Close #950 BREAKING CHANGE: Template strings inside templates are now disabled by default --- lib/loader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/loader.js b/lib/loader.js index 910dabf6..9340e157 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -25,7 +25,7 @@ module.exports = function (source) { // // Get templating options const options = this.query !== '' ? loaderUtils.getOptions(this) : {}; - const template = _.template(source, _.defaults(options, { variable: 'data' })); + const template = _.template(source, _.defaults(options, { interpolate: /<%=([\s\S]+?)%>/g, variable: 'data' })); // Require !!lodash - using !! will disable all loaders (e.g. babel) return 'var _ = require(' + loaderUtils.stringifyRequest(this, '!!' + require.resolve('lodash')) + ');' + 'module.exports = function (templateParams) { with(templateParams) {' +