Add support for caller() in variable declaration#724
Merged
GuillaumeGomez merged 3 commits intoaskama-rs:mainfrom Apr 12, 2026
Merged
Add support for caller() in variable declaration#724GuillaumeGomez merged 3 commits intoaskama-rs:mainfrom
caller() in variable declaration#724GuillaumeGomez merged 3 commits intoaskama-rs:mainfrom
Conversation
5bcb731 to
fc94c35
Compare
Contributor
|
Awesome! This functionality is nice for macro call nesting, since this: {%- macro outer() -%}
{%- set caller_ = caller -%}
<outer>
{%- call inner() -%}
{{- caller_() -}}
{%- endcall -%}
</outer>
{%- endmacro -%}
{%- macro inner() -%}
<inner>
{{- caller() -}}
</inner>
{%- endmacro -%}
{%- call outer() -%}
my content
{%- endcall -%}can become this, which is a little easier to understand (IMHO): {%- macro outer() -%}
{%- set content = caller() -%}
<outer>
{%- call inner() -%}
{{- content -}}
{%- endcall -%}
</outer>
{%- endmacro -%}
{%- macro inner() -%}
<inner>
{{- caller() -}}
</inner>
{%- endmacro -%}
{%- call outer() -%}
my content
{%- endcall -%}Would it make sense to add a unit-test that checks that the output of these two variants is identical? |
Collaborator
Author
|
Checking, might be a bug. But otherwise yes, gonna add a test to ensure both have the same output. |
Collaborator
Author
|
@seijikun That was a bug, but unrelated to this PR (I think?). Fixed it in the third commit. |
Collaborator
Author
|
Merging then. :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #506.
I think the other big missing feature. :)
Can you double-check @seijikun please?
Also cc @Kijewski since it's big feature (although in here, I mostly moved code around and copied
write_let_blockcode with modifications).