Hogan.js 互动版

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

Hogan.js用法

用它作为你的一部分资产打包编译模板提前或将它包括在你的浏览器来处理动态模板。

Hogan.js使用之前,先在引用Hogan.js。

<script src="hogan.js"></script>

Hogan.js使用方法:定义一组数据(data),通过Hogan.compile()方法编译,得到模版对象通过render()方法渲染数据。示例如下:

var data = {
  screenName: "dhg"
};

var template = Hogan.compile("Follow @{{screenName}}.");
var output = template.render(data);

// prints "Follow @dhg."
console.log(output);