How do I determine the last (final) layout in the layout chain when developing custom extension for template engine? #3157
Unanswered
monochromer
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to create an integration of Eleventy and Preact as a template engine
Eleventy passes the rendered template to the parent layouts inside the
content
property as raw HTML strings.For example, for the Nunjucks template engine, it looks like this
// index.md
// article.njk
// root.njk
But I want to pass objects, not strings. I don't know yet if these will be virtual nodes or functional components.
For Preact, it will look like this:
// index.md (I will replace default md render to custom method, which return components instead of html string)
// article.jsx
// root.jsx
But in the end, you still need to render the result to a string, like this:
How do I determine that the layout is the last one and I need to render everything in a string?
I had the idea to write a special property in the layout:
// root.jsx
Then, in the extension itself, determine the type of render based on this property (pseudocode):
But I want it to be transparent for the extension user and he does not need to manually set such flags.
Beta Was this translation helpful? Give feedback.
All reactions