-
Notifications
You must be signed in to change notification settings - Fork 641
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
Nested call/caller doesn't work. #664
Comments
It is important when you want to nest components with macros. Is there any progress on this issue? |
Nope. Usually you can easily work around it by doing a |
Seems I've created duplicate of this here: #799 You can note in my issue, that actually nesting of not macros directly, but
Though, I need to test it out exactly with your example. It's slightly different. |
@carljm I just tried that and it doesn't work: {% macro service(name, index, icon, cta_text) %}
{% set service_content = caller() %}
{{ service_content }} {# outputting here works #}
{% call base('section--service') %}
{% call elements.large_title(index) %}
<span class="text-primary">{{ name }}</span>
{% endcall %}
<div class="row">
<div class="col">
{{ service_content }} {# outputting here returns nothing #}
<btn class="btn btn-secondary">{{ cta_text }}</btn>
</div>
<div class="col">
{{ icon }}
</div>
</div>
{% endcall %}
{% endmacro %} Also note I've tried outputting I'm running |
Sample code:
This template should render as
<div><span>Foo</span></div>
, but instead it recurses infinitely and throwsRangeError: Maximum call stack size exceeded
.Fortunately there's a relatively simple workaround; redefine the
wrapdivspan
macro as follows, to avoid nesting the call tocaller()
inside acall
block:The nested version also fails in Jinja2 (though with
No caller defined
rather than infinite recursion). So it may not be a high priority to get this working in nunjucks, but it'd at least be nice if it failed with a clearer error.The text was updated successfully, but these errors were encountered: