Skip to content

Commit 1f4cf63

Browse files
committed
tweak template compilation error output
1 parent af61915 commit 1f4cf63

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/compiler/error-detector.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function checkFor (node: ASTElement, text: string, errors: Array<string>) {
5555

5656
function checkIdentifier (ident: ?string, type: string, text: string, errors: Array<string>) {
5757
if (typeof ident === 'string' && !identRE.test(ident)) {
58-
errors.push(`- invalid ${type} "${ident}" in expression: ${text}`)
58+
errors.push(`invalid ${type} "${ident}" in expression: ${text.trim()}`)
5959
}
6060
}
6161

@@ -66,11 +66,11 @@ function checkExpression (exp: string, text: string, errors: Array<string>) {
6666
const keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE)
6767
if (keywordMatch) {
6868
errors.push(
69-
`- avoid using JavaScript keyword as property name: ` +
70-
`"${keywordMatch[0]}" in expression ${text}`
69+
`avoid using JavaScript keyword as property name: ` +
70+
`"${keywordMatch[0]}" in expression ${text.trim()}`
7171
)
7272
} else {
73-
errors.push(`- invalid expression: ${text}`)
73+
errors.push(`invalid expression: ${text.trim()}`)
7474
}
7575
}
7676
}

src/platforms/web/compiler/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,10 @@ export function compileToFunctions (
111111
res.render === noop ||
112112
res.staticRenderFns.some(fn => fn === noop)
113113
) {
114-
const expressionErrors = detectErrors(compiled.ast)
114+
const allErrors = errors.concat(detectErrors(compiled.ast))
115115
_warn(
116116
`Error compiling template:\n\n${template}\n\n` +
117-
(errors.length ? errors.map(e => `- ${e}`).join('\n') + '\n' : '') +
118-
(expressionErrors.length ? expressionErrors.join('\n') + '\n' : ''),
117+
(allErrors.length ? allErrors.map(e => `- ${e}`).join('\n') + '\n' : ''),
119118
vm
120119
)
121120
}

0 commit comments

Comments
 (0)