Example #1
0
File: webx.js Project: hitme/plum
  layout: function(context){

    var vm = this._getLayoutString();
    var macros = this.globalMacros;
    var html = Velocity.Parser.parse(vm);

    var vmrun = new Velocity.Compile(html);
    vmrun.addIgnoreEscpape(['control', 'securityUtil', 'tbToken', 'stringEscapeUtil', 'enhanceToken'])
    var str = vmrun.render(context, getMacros(macros, this.get('basePath')));
    return str;

  }
Example #2
0
File: webx.js Project: hitme/plum
  parse: function(){

    var filePath = this.get('filePath');
    var vm = Iconv.decode(fs.readFileSync(filePath), 'gbk');
    var str = '';
    var isParse = this.get('isParse');
    var isJsonify = this.get('isJsonify');
    var file = this.get('file').replace('.htm', '.js');
    var context = this.getContext(file);
    var basePath = this.get('basePath');

    try {

      var html = Velocity.Parser.parse(vm);

      if (isParse) {

        str = JSON.stringify(html, false, 2);

      } else if (isJsonify) {

        str = this.jsonify(vm);

      } else {

        for(var i in this.tools)
          context[i] = this.tools[i];
        //context = utils.mixin(context, this.tools);

        var macros = this.globalMacros;
        var vmrun = new Velocity.Compile(html);
        vmrun.addIgnoreEscpape(['control', 'securityUtil', 'tbToken', 'stringEscapeUtil', 'enhanceToken'])
        str = vmrun.render(context, getMacros(macros, this.get('basePath')));

        var layout = this.layout(vmrun.context);
        str = layout.replace(/\$screen_placeholder/, str);
        this.tools.reset();

      }

      return Iconv.encode(str, 'gbk');
    } catch(e) {
      throw e;
    }
  },