Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何创建jsrender或jquery模板库_Jquery_Json_Templates_Jsrender - Fatal编程技术网

如何创建jsrender或jquery模板库

如何创建jsrender或jquery模板库,jquery,json,templates,jsrender,Jquery,Json,Templates,Jsrender,我需要从xml数据创建html模板,而无需在mvc应用程序中使用xslt 我的解决办法是: 首先,我使用json.net(http://json.codeplex.com/)将xml转换为json。 第二,我使用$parse.json将上面的json字符串转换为javascript对象文字(http://api.jquery.com/jQuery.parseJSON/) 第三,我使用了jsRender(https://github.com/BorisMoore/jsrender)向html模板添

我需要从xml数据创建html模板,而无需在mvc应用程序中使用xslt

我的解决办法是: 首先,我使用json.net(http://json.codeplex.com/)将xml转换为json。 第二,我使用$parse.json将上面的json字符串转换为javascript对象文字(http://api.jquery.com/jQuery.parseJSON/) 第三,我使用了jsRender(https://github.com/BorisMoore/jsrender)向html模板添加值

一切都好,一切都好。但是我需要为renderhtml编写自己的js,而不是jsRender

我的问题是:
如何循环遍历每个js对象,找到相关的html标记并添加值。

正如注释所暗示的,问题并不清楚

如果您使用的是JQuery,那么使用它提供的特性来循环元素。如果要使用原始javascript,请使用它提供的原语,如Object.keys


如果jsrender适合您,那么使用它来研究如何做事情。这是开放源码的主要目标之一——提供学习的基础。

欢迎使用。请将一些代码与您的问题一起发布,否则没有人能够回答!