A templating language that looks like Lisp and compiles to HTML
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

compiler.js 371B

1234567891011121314151617181920212223
  1. const AST = require('./ast')
  2. module.exports = class Compiler {
  3. constructor() {
  4. this.result = ''
  5. }
  6. compile(tree) {
  7. tree.forEach(node => {
  8. this.result += this.compileNode(node)
  9. })
  10. return this.result
  11. }
  12. compileNode(node) {
  13. switch (node.constructor) {
  14. case AST.Number:
  15. case AST.String:
  16. return node.value
  17. }
  18. }
  19. }