#1 2023-10-25 22:47:48

fastbike
Member
Registered: 2015-01-05
Posts: 3

Nested Mustache Partials

Is it possible to have deeply nested partials in this implementation of Mustache

E.g. I have a top level web page layout that has a a header content div, footer etc. Inside the content div I load the page specific content which includes a table, so this top level partial includes the table header/footer and calls another partial to iterate over a collection of objects to render the table rows.  Now the reason I'm using this next level partial is because we use HTMX to paginate through the data and having a separate template for the data rows makes the code reuse a lot easier (otherwise I have to maintain two identical copies of the row rendering templates).

<html>
<!-- header stuff -->
<body>
<!-- common body stuff-->
<!-- next line brings in a page to show some clinical information -->
{{>Classifications}}
</body>
</html>

The classifications page has

<table>
  <thead>
     <tr>
      <th scope="col"">Date</th>
      <th scope="col"">Classification Summary</th>
     </tr>
  </thead>			  
  {{>classification_data}}
  <tfoot>
    <tr>
      <td colspan="2">The summary</td>
    </tr>
  </tfoot>
</table>

And the table row template (classification_data) looks like this

<tbody> 
  {{#Classifications}}
  <tr>
     <td>{{DateFmt WarningDate, "dd mmmm yyyy"}}</td>
     <td>{{CodeDisplay}}</td>
  </tr>
  {{/Classifications}}
</tbody>	

I'd like the partial statement in the classifications page to fully parse any nested partials.
In case it is of relevance, this code is currently being called by the Mustache Renderer in the Delphi MVCFramework
https://github.com/danieleteti/delphimv … stache.pas

Last edited by fastbike (2023-10-25 22:49:23)

Offline

#2 2023-10-26 02:41:53

fastbike
Member
Registered: 2015-01-05
Posts: 3

Re: Nested Mustache Partials

OK, some more investigation has determined that this issue is due to the implementation of the Mustache Renderer within the DMVC framework. I have raised a ticket in that project with a suggested fix.
https://github.com/danieleteti/delphimv … issues/706

Offline

#3 2023-10-26 05:24:43

igors233
Member
Registered: 2012-09-10
Posts: 234

Re: Nested Mustache Partials

Note that this works in mORMot.

Offline

#4 2023-10-26 21:24:05

fastbike
Member
Registered: 2015-01-05
Posts: 3

Re: Nested Mustache Partials

igors233 wrote:

Note that this works in mORMot.

Thanks for the confirmation.
As a side note, it was interesting looking at the internals of the Synopse Mustache implementation, very nice - thank you.

Last edited by fastbike (2023-10-26 21:24:19)

Offline

Board footer

Powered by FluxBB