Skip to content

Support aliasing macro function names in {% from %} tag#1117

Merged
jasmith-hs merged 1 commit intomasterfrom
allow-macro-alias-in-from-tag
Oct 10, 2023
Merged

Support aliasing macro function names in {% from %} tag#1117
jasmith-hs merged 1 commit intomasterfrom
allow-macro-alias-in-from-tag

Conversation

@jasmith-hs
Copy link
Copy Markdown
Contributor

I just realised that this is something that I supported when implementing eager execution, but it was never supported in default execution. This is allowed in jinja, and we allow aliasing variables, so we should also allow aliasing macro functions:

From jinja docs:

Alternatively, you can import specific names from a template into the current namespace:

{% from 'forms.html' import input as input_field, textarea %}
<dl>
    <dt>Username</dt>
    <dd>{{ input_field('username') }}</dd>
    <dt>Password</dt>
    <dd>{{ input_field('password', type='password') }}</dd>
</dl>
<p>{{ textarea('comment') }}</p>

For example:
```
{% from 'file.jinja' import my_macro as m %}
```
@jasmith-hs jasmith-hs merged commit 963ad10 into master Oct 10, 2023
@jasmith-hs jasmith-hs deleted the allow-macro-alias-in-from-tag branch October 10, 2023 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant