M
M
Maxim Kononov2017-12-13 20:29:35
JavaScript
Maxim Kononov, 2017-12-13 20:29:35

How to build a Gulp task to precompile a Handlebars template from a .json file?

There is an array shop.json

{
  "items" : [{
"item1" : {
  "name" : "OXXXY",
  "price" : 2000,
  "available" : true,
  "size" : true,
  "img" : "/img/2.jpg"
},
"item2" : {
  "name" : "OXXXY",
  "price" : 2000,
  "available" : true,
  "size" : true,
  "img" : "/img/2.jpg"
}
}]
}

There is an html template
<script id="entry-template" type="text/x-handlebars-template">
  {{#each items}}
    <div class="item grid" style="background-image: url('{{img}}')">
      <a id="0001" href="#" class="item_content item_modal">
      <p class="text_dec dec1 decB">{{name}}</p>
      <p class="text_dec">{{price}}</p>
      </a>	
    </div>
  {{/each}}
  </script>

Help write a task for compilation. I would be very grateful.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question