Visitar URL original
Consider supporting .jinja2 extensions across the project · Issue #8603 · apache/airflow · GitHub
Skip to content

Consider supporting .jinja2 extensions across the project #8603

Open

Description

@oripwk

Description

At the moment, various operators support reading templates from given filenames (for example, bash_command of BashOperator). However, all of these operators specify extensions such as .sh, .json etc., so it means users need to write Jinja2 templates inside .sh, .json files. A better way to do it would be supporting the .jinja2 extension.

Use case / motivation

The motivation is threefold:

  1. .jinja2 extension is a widespread convention which is supported by various editors, including Github itself, PyCharm and VSCode.
  2. Putting templates inside .jinja2 can help distinguish between regular files and template files just by looking at the directory contents
  3. Working with tools that recognize .jinja2 templates can help reduce errors while authoring templates.

Related Issues

#8572 (comment)

Activity

  1. boring-cyborg commented on Apr 28, 2020

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template!

  2. mik-laj commented on Apr 28, 2020

    @mik-laj
    Member

    Hi.

    It looks good. I think we can accept jinja2 whenever template ext is not empty.
    Do you want to work on it? Should I assign you to this ticket?

    Best regards,
    Kamil

  3. oripwk commented on Apr 28, 2020

    @oripwk
    ContributorAuthor

    Hi,

    Yes, I can work on it. You can assign

  4. added a commit that references this issue on Apr 28, 2020
  5. potiuk commented on Apr 29, 2020

    @potiuk
    Member

    Hey @oripwk. I generally like the idea, but can you also write about this one on the devlist?

    I think this is quite a fundamental change int the approach for potentially many operators, and I feel we should have more people commenting on it and maybe coming up with some ideas how to handle it well. I think for example that better approach will be to simply support additional .jinja2 extension when you have extensions defined. For example when you have '.sh' extension in template extensions, you'd look in both *.sh and *.sh.jinja2 but not just *.jinja2. This way we might preserve both - nice formatting support from IDE's and semantic information about the actual type of the file. But this is just my opinion and maybe we can discuss it at the devlist.

    Woudl you be so kind to write about the proposal at the devlist please ?

  6. oripwk commented on Apr 29, 2020

    @oripwk
    ContributorAuthor

    Sure.
    I also commented on the PR regarding how to generate documentation for this, since it affects many operators. Do you have any suggestion how to deal with it? #8616 (comment)

  7. eladkal commented on May 5, 2021

    @eladkal
    Contributor

    @kaxil this issue should be resolved by #14603 correct?

  8. kaxil commented on May 6, 2021

    @kaxil
    Member

    @kaxil this issue should be resolved by #14603 correct?

    No, actually this is a bit different i.e. the OP wants to allow using "file.jinja2" instead of "file.bash" or "file.sql" in rendered template fields.

  9. uranusjr commented on Jul 31, 2024

    @uranusjr
    Member

    This would be irrelevant if AIP-80 is accepted. Instead of inferring from the extension, you’d need to pass in a FileTemplate class explicitly, which can accept any file name.

  10. added this to the Airflow 3.0.0 milestone on Jul 31, 2024
  11. self-assigned this
    on Jul 31, 2024
  12. bugraoz93 commented on Mar 16, 2025

    @bugraoz93
    Contributor

    Are we going to make this happen? I suggest we move to 3.1+ otherwise :)

  13. uranusjr commented on Apr 8, 2025

    @uranusjr
    Member

    Yes this should be moved to 3.1.

  14. potiuk commented on Mar 2, 2026

    @potiuk
    Member

    @oripwk We are unassigning you from this issue as part of our updated assignment policy.

    This is not meant to discourage your contribution — quite the opposite! You are still very welcome to work on this issue and submit a PR for it. Simply comment that you are working on it and open a PR when ready.

    We found that formal assignments were not working well, as they often prevented others from contributing when the assignee was not actively working on the issue.

  15. amoghrajesh commented on Mar 25, 2026

    @amoghrajesh
    Contributor

    Since this has not yet been picked up and we are approaching the 3.2 release, I am moving it to the 3.3 milestone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions