#1 Re: mORMot 2 » Nested Mustache Partials » 2023-10-26 21:24:05

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.

#2 Re: mORMot 2 » Nested Mustache Partials » 2023-10-26 02:41:53

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

#3 mORMot 2 » Nested Mustache Partials » 2023-10-25 22:47:48

fastbike
Replies: 3

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

Board footer

Powered by FluxBB