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,
),
)
}
}
// 递归解析
content += vm.render(vmVfile.targetContent, {
dataObj: dataObj,
dirname: path.dirname(vmpath),
existMap: existMap
});
content += ``;
return content;
}
}
return velocity.render(vmSource, dataObj, macros);
}
if (params.querystring && !_.isUndefined(params.querystring[key])) {
return params.querystring[key];
}
if (params.header && !_.isUndefined(params.header[key])) {
return params.header[key];
}
return null;
}
}
};
// Always keep macros empty, API gateway doesn't support those
const result = velocity.render(template, data, {});
return _.unescape(result);
};
resolvers[typeName][fieldName] = async (root, args, context) => {
const d = new Date();
console.log(
`Resolver`,
chalk.black.bgBlue(fieldName),
`executed at ${d.toLocaleTimeString()}`
);
console.log("Rendering velocity template...");
let template = velocity.render(requestMappingTemplate, {
context: {
arguments: JSON.stringify(args),
request: {
headers: JSON.stringify(context.request.headers)
},
identity: JSON.stringify(context.identity)
}
});
template = JSON.parse(template);
const payload = JSON.parse(JSON.stringify(template.payload));
if (!options.quiet) {
const headers = template.payload.headers;
if (headers !== undefined && headers !== null) {
Object.keys(headers).map(function(key, index) {
headers[key] =
public parse(content: string): TemplateSymbol[] {
const symbols: TemplateSymbol[] = [];
const tokens: any[] = Velocity.parse(content);
for (const token of tokens) {
if (token.type === 'references') {
symbols.push(new TemplateSymbol(token.id, 'string'));
}
}
return symbols;
}
protected validate(text: string, errors: any[]): void {
try {
const tokens: any[] = Velocity.parse(text);
let totalSymbols = 0;
for (const token of tokens) {
if (token.type === 'references') {
totalSymbols++;
}
}
if (totalSymbols === 0) {
const msg = 'linter-no-symbols';
errors.push({
from: CodeMirror.Pos(0, 0),
message: msg,
severity: 'warning',
to: CodeMirror.Pos(0, 0),
});
}
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;
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;
}