Skip to content

Commit c8cf57d

Browse files
committed
simplify template preprocessor
1 parent bd525fd commit c8cf57d

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

lib/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ module.exports = function (content) {
254254
// unknown lang, infer the loader to be used
255255
switch (type) {
256256
case 'template':
257-
return defaultLoaders.html + '!' + templatePreprocessorPath + '?raw&engine=' + lang + '!'
257+
return defaultLoaders.html + '!' + templatePreprocessorPath + '?engine=' + lang + '!'
258258
case 'styles':
259259
loader = addCssModulesToLoader(defaultLoaders.css, part, index)
260260
return loader + '!' + styleCompiler + ensureBang(ensureLoader(lang))

lib/template-compiler/preprocessor.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,12 @@
22

33
var cons = require('consolidate')
44
var loaderUtils = require('loader-utils')
5-
var extname = require('path').extname
65

76
module.exports = function (content) {
87
this.cacheable && this.cacheable()
98
var callback = this.async()
109
var opt = loaderUtils.getOptions(this) || {}
1110

12-
// this is never documented and should be deprecated
13-
// but we'll keep it so we don't break stuff
14-
var vue = this.options.__vueOptions__
15-
if (vue && vue.template) {
16-
for (var key in vue.template) {
17-
opt[key] = vue.template[key]
18-
}
19-
}
20-
21-
function exportContent (content) {
22-
if (opt.raw) {
23-
callback(null, content)
24-
} else {
25-
callback(null, 'module.exports = ' + JSON.stringify(content))
26-
}
27-
}
28-
29-
// with no engine given, use the file extension as engine
30-
if (!opt.engine) {
31-
opt.engine = extname(this.request).substr(1).toLowerCase()
32-
}
33-
3411
if (!cons[opt.engine]) {
3512
return callback(new Error(
3613
'Template engine \'' + opt.engine + '\' ' +
@@ -45,6 +22,6 @@ module.exports = function (content) {
4522
if (err) {
4623
return callback(err)
4724
}
48-
exportContent(html)
25+
callback(null, html)
4926
})
5027
}

0 commit comments

Comments
 (0)