Closed zaiste closed 6 years ago
Including the input in the include
tag is the right approach here. I'd argue that hiding it in some automagic that the compiler does would make reasoning about where the values in base.marko
and meta.marko
are coming from much more difficult to understand. It would also make testing in isolation harder.
Is it really that big of a deal to add <include('../layouts/base.marko', input) />
to your index.marko
file?
@jasonmacdonald it's not a big deal. I just wanted to make it easier for the end users of my tool. Thank you for the clarification!
I'm working on a static site generator called Kulfon. I've decided to replace Nunjucks with Marko for the templating to eventually make something similar to Gatsby. Currently I'm only using
<include>
along withrenderToString()
to construct final HTML pages.I'm splitting templates into 3 directories:
layouts/
,partials/
andpages/
(at some point I'll also addcomponents/
).Here's a simplified layout:
Here's
index.marko
page:And here's how I render the final HTML:
The problem is that
input.title
in only visible withinindex.marko
page. I cannot read this value inside the layout unless I pass it explicitly through<include(..., input)/>
. In some scenarios I may also need this data in included partials e.g.meta.marko
.Is it possible to force the compiler to include the
input
values within the context of a single HTML that is generated from a single layout + multiple partials ?