Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const renderResult = runInPollutedScope(() =>
// This line can throw, but this function does not handle errors
// Quick args explanation:
// { escape: false } --> otherwise would escape &, < and > chars with html (&, < and >)
// render(context, null, true) --> null: no custom macros; true: silent mode, just like APIG
new Compile(parse(velocityString), { escape: false }).render(
context,
null,
true,
),
)
import { parse, Compile } from 'velocityjs';
const asts = parse(document.querySelector('#tmpl').innerHTML);
const data = {
items: [{ a: '1' }, { a: 'successed' }],
};
const s = new Compile(asts).render(data);
document.querySelector('.foo').innerHTML = s;
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;
}
},
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;
}
this._add();
var dataFile = path.dirname(filePath) + '/.data/' + path.basename(filePath);
var data = {};
if (fs.existsSync(dataFile)) {
data = JSON.parse(fs.readFileSync(dataFile).toString());
}
var vm = fs.readFileSync(filePath).toString();
try {
var html = Velocity.Parser.parse(vm);
if (isParse) {
this.fire('set:header', {type: '.json'});
var str = JSON.stringify(html, false, 2);
} else {
str = new Velocity.Compile(html).render(data);
}
this.fire('end', {index: i, data: str});
} catch(e) {
this.fire('end', {index: i, data: '<pre>' + e.toString()});
throw e;
}
}
</pre>