Es la primera vez que pruebo manillares. De alguna manera no puedo obtener la matriz en uno de los objetos.
Esto es lo que obtengo actualmente:
eric alan
Así es como espero que la salida sea como:
Eric 2019-01-01 Eric Escriba un Eric 2019-12-31 Eric Escriba un Alan 2020-01-01 Alan Escriba un
A continuación se muestra el código de trabajo, pero no puedo obtener la fecha y el tipo de {{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>Una posible solución sería:
{{#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}}