Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
// 递归解析
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] =
const vtl = (str, context, macros = {}) => {
log.info('render\n', str);
const output = velocity.render(str, context, macros, {
valueMapper: javaify,
});
log.info('render output\n', output);
return output;
};
app.engine('html', function(path, options, fn) {
var template = fs.readFileSync(path).toString(),
macros = {
parse: function(file) {
var template = fs.readFileSync(process.cwd() + '/views/' + file).toString();
return this.eval(template);
}
};
try {
fn(null, velocity.render(template, options, macros));
} catch (err) {
fn(err)
}
});