有人知道如何将 Json 数据绑定到 HandleBar 吗?
这是来源:https ://github.com/rexm/Handlebars.Net
我可以检查这个例子:
string source =
@"<div class=""entry"">
<h1>{{title}}</h1>
<div class=""body"">
{{body}}
</div>
</div>";
var template = Handlebars.Compile(source);
var data = new
{
title = "My new post",
body = "This is my first post!"
};
var result = template(data);
它工作正常,但我将数据转换为 json,而且,我需要在 html 中进行迭代。例如,这可能是 json:
{"Threshold":12,"Server":[{"Name":"Machine1","CpuUsage":27,"RamUsage":62},{"Name":Machine2","CpuUsage":25,"RamUsage":57}]}
谢谢