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

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

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

jasmith-hs
Copy link
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
4 checks passed
@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