-
Notifications
You must be signed in to change notification settings - Fork 172
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: @partial-block for nunjucks engine #1105
Comments
You should be able to use a regular variable in your component for the partial/block content. Then, in the parent component, use the set tag to create a variable block, then pass it into the child. |
Otherwise, this seems like a wish for a twig-like embed tag: mozilla/nunjucks#790 That issue has been open for five years with no solution. Even Mark, Fractal's creator, supported that addition. I would recommend for this to be requested upstream, as it's not really a Fractal-specific feature. |
@mihkeleidast Thank you for your feedback. I will try the My idea was, that the tag should resolve a component, so I thought it would be fractal specific. But the |
I think it would get the same template path resolving logic that the primary include et al tags use, so should not need anything specific for Fractal! |
@mihkeleidast Ok, thanks. I tried the ´{% set ... %}` approach, but this does not seem to work. My template looks like
The result is
It looks like, that the |
What problem would this feature solve?
The handlebars engine supports partial-blocks, making it possible to create wrapper components or override a component's content from parent/including template. I could not find a way to achieve the same result when using nunjucks as template engine.
What the feature should look like?
A nice way would be a
partial
tag, that renders the content between{% partial '@container-partial' %}
and{% endpartial %}
and make the result usable as variable or function in thecontainer-partial
. This would be similar to nunjucks{% call 'someMacro' %}...{% endcall %}
tag using{{ caller() }}
inside the macro to render/output the tag body.I'm not familiar with the internals of either fractal or nunjucks, so I'm not able to create that myself. Therefore I hope, someone has the knowledge and the time to do that.
The text was updated successfully, but these errors were encountered: