Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.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
Html 如何使用下划线.js从json呈现模板_Html_Json_Underscore.js_Underscore.js Templating - Fatal编程技术网

Html 如何使用下划线.js从json呈现模板

Html 如何使用下划线.js从json呈现模板,html,json,underscore.js,underscore.js-templating,Html,Json,Underscore.js,Underscore.js Templating,我想知道如何将json对象呈现为下划线模板:下面是我的json数据: $('#testinfoWidget').testInfo({ // where testInfo is the jquery widget I created. width: 300, title: 'Test Info', content:{name: 'test 2', status: 'FINISHED',region: 'Washington DC'} }); 我的html: <div

我想知道如何将json对象呈现为下划线模板:下面是我的json数据:

 $('#testinfoWidget').testInfo({   // where testInfo is the jquery widget I created.
   width: 300,
   title: 'Test Info',
   content:{name: 'test 2', status: 'FINISHED',region: 'Washington DC'}
});
我的html:

<div class="info loadtestinfo" id="testinfoWidget">
<ul class="contentBox boxHighlight" id = "contentBox"></ul></div>
有人有什么想法吗


当您将对象按原样提供给模板时会发生什么?如果您向我们展示了您的具体操作,我们可能会指出您的错误所在。在jsfiddle.net上进行一次演示(包括示例数据)也会有所帮助。
<script type = "test/javascript" id = "usageList">
`<li class="contentBoxHeader"><%- title %></li>`
  `<li class="contentBoxContent">`   
           `<table class="simpleTable" id ="simpleTable">` 

           <tr>
            <td class="label">Name:</td>
            <td class="value"><%- content.name %></td>
          </tr>
            <tr>
                <td class="label" style="vertical-align: top;">Status:</td>
                <td class="value">
                    <span id="test_state"><%- content.status %></span>
                </td>
            </tr>
            <tr>
                <td class="label">Region:</td>

                <td class="value"><%- content.region %></td>

            </tr>
            <tr>
                <td class="label">Start:</td>
                <td class="value"><%- content.start %></td>
            </tr>
            <tr>
                <td class="label">End:</td>
                <td class="value"><%- content.end %></td>
            </tr>
        </table>
</li>
Title: Test Info
Name: test2
Region: Washnigton DC
Status: FINISHED.