Django TemplateYAK
YAK in Django TemplateYAK stands for Yet Another Komponent.
This library provides class-based templatetags for Django.
Writing templatetags in Django that don't fit simple_tag or inclusion_tag is non-trivial. Class-based templatetags is an attempt at making it less complicated.
As a bonus, you'll find a Django Komponent system also included in this library. You can use it straight out of the box or as a reference for implementing your own templatetags.
Installation
From git
pip install git+https://gitlab.levitnet.be/emma/django-yak@main
From source
Within the source directory
python setup.py install
Configuration
Templatetags only
If you intend to use Django TemplateYAK for building your own templatetags, no further configuration is required.
Components
You will need to add yak
to your INSTALLED_APPS
.
You may also wish to add yak
to TEMPLATES
's builtins:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'DIRS': [],
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'builtins': [ # This item here
'yak.templatetags.yak',
]
},
},
]
Components with dj-angles
If you'd like to use components with dj-angles, you'll have to configure your TEMPLATES
according to dj-angles installation instructions.
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# IMPORTANT: No 'APP_DIRS'
'DIRS': [],
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'loaders': [
(
'django.template.loaders.cached.Loader',
[
'dj_angles.template_loader.Loader', # dj-angles loader
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
],
)
],
'builtins': [ # This bit is optional
'yak.templatetags.yak',
]
},
},
]
You will also need to add YAK's mapper to dj-angles