Browse Source

Manage the whitespace produced by the compiler

master
Dylan Baker 5 years ago
parent
commit
69dc0975d0
1 changed files with 2 additions and 6 deletions
  1. 2
    6
      src/compiler.js

+ 2
- 6
src/compiler.js View File

@@ -11,11 +11,7 @@ module.exports = class Compiler {
11 11
         const attributes = node.args.map(arg => `${arg.attributeName}="${this.compileAttribute(arg.attributeValue)}"`)
12 12
         const compiler = new Compiler(node.subtree, this.context)
13 13
         const content = compiler.compile()
14
-        this.result += `
15
-          <${node.functionName}${attributes.length ? ' ' : ''}${attributes.join(' ')}>
16
-            ${content}
17
-          </${node.functionName}>
18
-        `
14
+        this.result += `<${node.functionName}${attributes.length ? ' ' : ''}${attributes.join(' ')}>${content}</${node.functionName}>`
19 15
       } else if (node.type === 'string') {
20 16
         this.result += node.content
21 17
       } else if (node.type === 'identifier') {
@@ -23,7 +19,7 @@ module.exports = class Compiler {
23 19
       }
24 20
     })
25 21
 
26
-    return this.result
22
+    return this.result.trim()
27 23
   }
28 24
 
29 25
   compileAttribute(attribute) {

Loading…
Cancel
Save