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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 三种调度算法报错 有实例
    • ¥15 关于#python#的问题,请各位专家解答!
    • ¥200 询问:python实现大地主题正反算的程序设计,有偿
    • ¥15 smptlib使用465端口发送邮件失败
    • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
    • ¥15 对于squad数据集的基于bert模型的微调
    • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
    • ¥20 steam下载游戏占用内存
    • ¥15 CST保存项目时失败
    • ¥20 java在应用程序里获取不到扬声器设备