Mariano Montone (@mmontone) on GitLab, 2018-10-14.
0 commits, 0 files changed
Administrator (@root) on GitLab, 2018-10-14.
It's unclear to me why you would need to render the template, as I don't see where this template will be getting the required context from: after all, the context is passed to the second render invocation, which renders the template and inserts the generated content.
(Meaning: please help me understand why this works)
Mariano Montone (@mmontone) on GitLab, 2018-10-14.
It's needed because the newsbox is rendered as a mustache partial and so you need to invoke mustache on the page content setting up the variables so that partials are found and rendered. {> newsbox} in index page is the partial.
Mariano Montone (@mmontone) on GitLab, 2018-10-14.
I should probably add a comment to the code so this is understood.
Mariano Montone (@mmontone) on GitLab, 2018-10-14.
Also, the toplevel mustache render doesn't work because it inserts page-content like this:
<main role="main" class="container main">
{{{page-content}}}
</main>
And not as a partial (subtemplate) (question here: is it possible to have dynamic partials in mustache?). So, page-content is not processed as a mustache template, which is what is needed for for example the index page, that contains mustache tags like {> newsbox}. That's why rendering page-content first via mustache is needed.
Hope this is not all too confusing.
Administrator (@root) on GitLab, 2018-10-14.
I understand most of what you're saying, but I don't understand where the content for the newsbox is coming from. (Can't we just process the page content as a mustache partial? Maybe you can experiment with that?)
Mariano Montone (@mmontone) on GitLab, 2018-10-14.
Yes. Perhaps. But we'd need a "dynamic partial", something like {> current-page} , where current-page is set as some context variable. Ok, I'll look.
Mariano Montone (@mmontone) on GitLab, 2018-10-14.
There's no official support of dynamic partials or inheritance in markdown. And implementing dynamic partials would be very similar to what we are doing already. What we are doing could be considered a bit dirty, but the truth is there's no support. I'd leave it as it is, with some comments in the code explaining what's going on.
Erik Huelsmann (@ehuelsmann) on GitLab, 2018-10-15.
What I was probably missing is that "partials" are being read from disc, which means that it's enough for the "partial" to exist on disc and there's no immediate state (in memory) which influences processing the partials that need to be included such as the news box. I think this fact (that some content includes partials, read from disc) makes for a nice comment in the code to explain why the contents actually needs evaluation yet doesn't really need a context.
Sign in to comment.