Beispiel #1
0
Compiler.prototype.generate = function generate(code) {
  if (this.options['no-opt'] || this.options.optimize === false) {
    var source = '/// -------------------------------------\n' +
                 '/// --------- BEM-XJST Runtime Start ----\n' +
                 '/// -------------------------------------\n' +
                 bemhtml.runtime + ';\n' +
                 ';\n' +
                 '/// -------------------------------------\n' +
                 '/// --------- BEM-XJST Runtime End ------\n' +
                 '/// -------------------------------------\n' +
                 '\n' +
                 '/// -------------------------------------\n' +
                 '/// ------ BEM-XJST User-code Start -----\n' +
                 '/// -------------------------------------\n' +
                 code + ';\n' +
                 '/// -------------------------------------\n' +
                 '/// ------ BEM-XJST User-code End -------\n' +
                 '/// -------------------------------------\n' +
                 '__$flush();\n';
    return this.wrap(xjst.generate(source, this.options));
  }

  var ast = esprima.parse(code, {
    loc: true
  });

  ast = this.translate(ast, code);

  var out = uglify.AST_Node.from_mozilla_ast(ast).print_to_string({ beautify: true });

  return this.wrap(out);
};
Beispiel #2
0
Compiler.prototype.generate = function generate(code) {
  if (this.options['no-opt'] || this.options.optimize === false) {
    return xjst.generate(bemhtml.runtime + ';\n' +
                         (this.options.ibem === false ? '' : bemhtml.ibem) +
                         ';\n' +
                         code + ';\n' +
                         '__$flush();\n',
                         this.options);
  }

  var ast = esprima.parse(code);

  ast = this.translate(ast);

  return uglify.AST_Node.from_mozilla_ast(ast).print_to_string();
};