dongpang2483 2017-02-17 06:47
浏览 288

如何使用handlebars.js处理json数据

I'm confused how can I get this json data through handlebars, this is from connecting into a api sample.. thank you so much .

[
  {
    "template_name": "Sample",
    "preview_url": "http://sample.com",
    "thumbnail_url": "https://sample.jpg",
    "template_id": 10010101,
    "template_properties": {
      "can_build_from_url": false
    }
  },
   {
    "template_name": "Sample",
    "preview_url": "http://sample.com",
    "thumbnail_url": "https://sample.jpg",
    "template_id": 10010101,
    "template_properties": {
      "can_build_from_url": false
    }
  },
  {
    "template_name": "Sample",
    "preview_url": "http://sample.com",
    "thumbnail_url": "https://sample.jpg",
    "template_id": 10010101,
    "template_properties": {
      "can_build_from_url": false
    }
  }
]

this is my code trying to get the data from my javascript templating using handlebars:

  <script id="apiTemplate" type="text/template">


        <div class="templates">
      <div class="photo-col">
        <img src="{{thumbnail_url}}" alt="" />
      </div>
      <div class="info-col">
        <h2 class="temp-name">Template Name: {{template_name}}</h2>
        <ul>
          <li>ID: {{template_id}}</li>
          <li>Can build from URL: {{template_properties.can_build_from_url}}</li>
        </ul>
        <div class="start">
          <a href="{{preview_ur}}"><button>Preview Temaplate</button></a>
        </div>

      </div>
    </div>

  </script>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料