Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

79
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda