Skip to content

Commit 76d9a76

Browse files
committed
added handlebars template test
1 parent 8aa5a92 commit 76d9a76

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
"css-loader": "^0.26.1",
3939
"debug": "^2.3.3",
4040
"dynavers": "^0.2.0",
41+
"handlebars": "^4.0.6",
42+
"handlebars-loader": "^1.4.0",
4143
"html-webpack-plugin": "^2.24.1",
4244
"jasmine": "^2.5.2",
4345
"jasmine-spec-reporter": "^2.7.0",

spec/core-spec.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ describe(`Core functionality (webpack ${version.webpack})`, function () {
186186
testPlugin(config, expected, done);
187187
});
188188

189-
fit('plays happily with other plugins on the same html plugin event', (done) => {
189+
it('plays happily with other plugins on the same html plugin event', (done) => {
190190
const config = baseConfig(
191191
{
192192
defaultAttribute: 'async'
@@ -334,4 +334,24 @@ describe(`Core functionality (webpack ${version.webpack})`, function () {
334334
];
335335
testPlugin(config, expected, done);
336336
});
337+
338+
it('works with handlebars template <script> elements', done => {
339+
const config = baseConfig({}, 'index_bundle.js');
340+
config.entry = path.join(__dirname, 'fixtures/script1.js');
341+
config.plugins = [
342+
new HtmlWebpackPlugin({
343+
template: '!!handlebars-loader!spec/fixtures/handlebars_template.hbs',
344+
testMsg: 'Hello World'
345+
}),
346+
new ScriptExtHtmlWebpackPlugin({
347+
defaultAttribute: 'async'
348+
})
349+
];
350+
const expected = baseExpectations();
351+
expected.html = [
352+
/(<script type="text\/javascript" src="index_bundle.js" async><\/script>)/,
353+
/(<script>[\s\S]*Hello World[\s\S]*<\/script>)/
354+
];
355+
testPlugin(config, expected, done);
356+
});
337357
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="x-ua-compatible" content="ie=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
8+
<body>
9+
10+
<script>console.log('
11+
{{#if htmlWebpackPlugin.options.testMsg}}
12+
{{htmlWebpackPlugin.options.testMsg}}
13+
{{else}}
14+
Missing Test Message
15+
{{/if}}
16+
');
17+
</script>
18+
19+
</body>
20+
</html>
21+

0 commit comments

Comments
 (0)