nodejs json-t 基本测试

安装npm包

npm i json-templater
or
yarn add json-templater

基本代码

var render = require('json-templater/string');
console.log(render('<div class="font-size:{{size}}">{{xfoo}} {{say.what}}</div>', { xfoo: 'yep', say: { what: 'yep' },size:"100px" }));
var object = require('json-templater/object');
var template={
"magic_key_{{magic}}": {
"key": "interpolation is nice {{value}}"
}
}
console.log(object(
template,
{ magic: 'key', value: 'value' }
));

输出结果

参考资料

https://www.npmjs.com/package/json-templater

posted on 2018-07-24 18:53  荣锋亮  阅读(415)  评论(0编辑  收藏  举报

导航