Goro
Goro

Reputation: 10249

Jinja - load custom template tag set

Is there a way to load a custom tag set - or even individual custom tags?

In django templates, I was able to do this:

{% load custom_tag_set %}

Is there a way to do this in jinja?

Upvotes: 5

Views: 8440

Answers (2)

gitaarik
gitaarik

Reputation: 46420

Since Django 1.8, Jinja2 is a built-in option as a template backend. In the Django docs they describe how to simulate some of Django's native template engine's context processors, filters and tags:

https://docs.djangoproject.com/en/1.8/topics/templates/#django.template.backends.jinja2.Jinja2

There's also a project with extensions for Jinja2 that simulate some template tags from Django. They work the same as Django's template tags but are essentially less Jinja2-onic:

https://github.com/MoritzS/jinja2-django-tags

Upvotes: 0

bchhun
bchhun

Reputation: 18484

The same mechanism exists but with a different name.

It's called Extensions

Upvotes: 8

Related Questions