Skip to content

Commit

Permalink
fix(ast): trim whitespace in tag end
Browse files Browse the repository at this point in the history
Closes #3
  • Loading branch information
thetutlage committed Oct 16, 2017
1 parent 5bc9889 commit 2ff8b36
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Ast/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class Ast {
_tokenForTag (line, tag, args, index, selfClosing) {
return {
tag,
args: args ? args.replace(/\)$/, '') : undefined,
args: args ? args.trim().replace(/\)$/, '') : undefined,
selfClosing,
childs: [],
body: line,
Expand Down
24 changes: 24 additions & 0 deletions test/unit/template.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,30 @@ test.group('Template Compiler', (group) => {
const inlineOutput = template.compileString(inlineStatement)
assert.equal(output, inlineOutput)
})

test('trim component name white space', (assert) => {
const statement = `
<html>
<body>
@include('content')
</body>
</html>
`
const template = new Template(this.tags, {})
const output = template.compileString(statement)

assert.equal(output, dedent`
return (function templateFn () {
let out = new String()
out += \`<html>\\n\`
out += \` <body>\\n\`
out += \`\${this.runTimeRender('content')}\`
out += \` </body>\\n\`
out += \` </html>\\n\`
return out
}).bind(this)()
`)
})
})

test.group('Template Runner', () => {
Expand Down

0 comments on commit 2ff8b36

Please sign in to comment.