Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

77
Views
Handlebars - multiple objects

It is my first time trying out handlebars. Somehow I'm not able to get the array in one of the object.

This is what I get currently:

Eric Alan

This is how I expect the output to be like:

Eric 2019-01-01 Eric Type a Eric 2019-12-31 Eric Type a Alan 2020-01-01 Alan Type a

Below is the working code but i unable to get the date and type from {{list_of_date}}:

$(function() {
  var source = $("#document-template").html();
  var template = Handlebars.compile(source);
  var html = template(data);
  $('#DocumentResults').html(html);
});



var data = [{
  users: [{
    name: 'Eric',
    list_of_date: [{
      "2019-01-01": [{
        "id": "1",
        "type": "Eric Type a",
      }],
      "2019-12-31": [{
        "id": "2",
        "type": "Eric Type b",
      }]
    }],
  }, {
    name: 'Alan',
    list_of_date: [{
      "2020-01-01": [{
        "id": "1",
        "type": "Alan Type a",
      }]
    }],
  }]
}];
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<div id="DocumentResults"></div>
<script id="document-template" type="text/x-handlebars-template">
  <div>
    {{#each this}} 
      {{#users}} 
        {{name}} 
      {{/users}} 
    
      {{#list_of_date}} 
        {{type}}
      {{/list_of_date}} 
      
    {{/each}}
  </div>
</script>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

A possible solution would be:

{{#each this}} 
 {{#each users as | user |}} 
  {{user.name}} 
  {{#each user.list_of_date as | userDateItem |}}
   {{#each userDateItem as |toDisplay|}}
    {{@key}}
    {{toDisplay.[0].type}}
   {{/each}}
  {{/each}}
 {{/each}} 
{{/each}}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!