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

Add basic jinja extension #417

Closed
wants to merge 3 commits into from
Closed

Add basic jinja extension #417

wants to merge 3 commits into from

Conversation

seb-b
Copy link

@seb-b seb-b commented Feb 2, 2024

Added a basic built-in jinja extension, should mean integrating with jinja templates requires a little less wiring up for the user, no need to create a custom extension in the project. If more template tags are added in the future they can be added to the built-in extension as well.

@adamchainz
Copy link
Owner

Django recommends creating a custom environment and adding things into it: https://docs.djangoproject.com/en/5.0/topics/templates/#django.template.backends.jinja2.Jinja2 (scroll down a bit).

I don't see what adding an extension really adds over using this pattern, at least for this single template tag. If there were more, maybe. I may add one to my heroicons project, for example.

@seb-b
Copy link
Author

seb-b commented Feb 4, 2024

It doesn't add a whole lot that's true, it's more of a convenience. If I add django-htmx to my project and have no need for other custom tags then I only need to add one line to my template config. A few other libraries I use follow this pattern.

If it adds more maintenance overhead than it's worth, happy to for this to be closed

@adamchainz
Copy link
Owner

A few other libraries I use follow this pattern.

Out of interest, can you link to them?


I think I’ll stick with the status quo here, for now. But I’ll keep an extension in mind if there are ever more tags. Thanks!

@adamchainz adamchainz closed this Feb 5, 2024
@seb-b
Copy link
Author

seb-b commented Feb 8, 2024

Mainly Wagtail - https://docs.wagtail.org/en/stable/reference/jinja2.html#jinja2

Few other ones are for wagtail extensions (but most of those are maintained by us)

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.

2 participants