Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.

Commit aa01c63

Browse files
committed
deal with 1.0 syntax in the HTML minifier (fix #19)
1 parent 31ac744 commit aa01c63

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ var async = require('async')
1010
var compilers = require('./compilers')
1111
var Emitter = require('events').EventEmitter
1212

13+
// required for Vue 1.0 shorthand syntax
14+
var htmlMinifyOptions = {
15+
customAttrSurround: [[/@/, new RegExp('')], [/:/, new RegExp('')]]
16+
}
17+
1318
var compiler = module.exports = new Emitter()
1419

1520
// expose method for registering custom pre-processors
@@ -110,7 +115,7 @@ compiler.compile = function (content, filePath, cb) {
110115

111116
// template
112117
if (template) {
113-
template = JSON.stringify(htmlMinifier.minify(template))
118+
template = JSON.stringify(htmlMinifier.minify(template, htmlMinifyOptions))
114119
output += 'var __vue_template__ = ' + template + ';\n'
115120
}
116121

test/expects/basic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require("insert-css")("html{font-size:20px}");
2-
var __vue_template__ = "<h1>hello</h1>";
2+
var __vue_template__ = "<h1 :id=\"id\" @click=\"hi\">hello</h1>";
33
var a = 123
44
module.exports = {
55
data: function () {

test/fixtures/basic.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</style>
66

77
<template>
8-
<h1>hello</h1>
8+
<h1 :id="id" @click="hi">hello</h1>
99
</template>
1010

1111
<script>
@@ -15,4 +15,4 @@ module.exports = {
1515
return 123
1616
}
1717
}
18-
</script>
18+
</script>

0 commit comments

Comments
 (0)