Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: assemble partials without rendering variables #1804

Open
yespire opened this issue Dec 22, 2021 · 0 comments
Open

Feature: assemble partials without rendering variables #1804

yespire opened this issue Dec 22, 2021 · 0 comments
Labels

Comments

@yespire
Copy link

yespire commented Dec 22, 2021

h.registerPartial("p1", "p1")
h.registerPartial("p2", "p2")
let output = h.compile("partials: {{> p1}} + {{> p2}}, variables: {{v1}} + {{v2}}")()

right now, this produces "partials: p1 + p2, variables: + "

need a way to produce "partials: p1 + p2, variables: {{v1}} + {{v2}}"

proposed syntax:

h.registerPartial("header", header_tpl)
h.registerPartial("footer", footer_tpl)
var assembled_page_tpl = h.assemblePartials(page_tpl)
h.compile(assembled_page_tpl)(data)

What difference will this method make:

  • right now, render-entry-point is the "content_tpl", which references the layout it use, this can become repetitive if you have a lot of pages
  • with assemblePartials(), the render-entry-point is the outer page, this means sub-templates do not need to reference the parent, this is more logical

Here is an example folder structure
image
You can arrange a convention based template assembling logic in your project, which also support specific folder layout/partials to override the general layout/partials, in the above folder structure, legal/terms + privacy will use the following without specifying layout in template:

@sub/page
@sub/body
legal/@sub/header
legal/@sub/footer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants