Skip to main content

Cofingo is a combination of Coffin (http://github.com/coffin/coffin) and Jingo (http://github.com/jbalogh/jingo). It allows the usage of Jinja2 templates while keeping the tags and filters from Django (e.g. the URL tag)

Like Jingo the way to add custom filters, tags (extensions), and tests is by creating a helpers.py file in your app.

Getting started

The easiest way to install Cofingo is by using pip:

pip install django-cofingo

The development version can be found at:

http://github.com/mvantellingen/django-cofingo

Configuration

Add django_cofingo.Loader to your settings:

TEMPLATE_LOADERS = (
    'django_cofingo.Loader',
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

Templates are then rendered by Jinja2 whichever method is used (It works for class based views, TemplateResponse etc).

If you want to prevent that the templates of a specific app are rendered with Jinja2 then you can excluded them in your settings file:

COFINGO_EXCLUDED_APPS = ['admin', 'debug_toolbar']

(Note that these two apps are added by default)

Creating custom filters and extensions

Create a helpers module in your django app and add the following:

from django_cofingo.library import Library

library = Library()

If you want to add a filter add the following:

@library.filter
def my_custom_filter(value):
    return value + '-filtered'

Adding an extension can be done as follow:

from django_cofingo.library import Library
from django_assets.env import get_env
from webassets.ext.jinja2 import AssetsExtension

library = Library()
library.attr('assets_environment', get_env())
library.extension(AssetsExtension)

You can also add other modules with a library to Cofingo by specifying them in your settings.py file:

COFINGO_HELPERS = [
    'myproject.helpers'
]

Release files for django-cofingo 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-cofingo 0.2.2
File Size Uploaded
django-cofingo-0.2.2.tar.gz 17.2 kB Details

Release files / django-cofingo-0.2.2.tar.gz

Download URL django-cofingo-0.2.2.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5da048abf9260de99e28951920bb57c0e052f275f4e0123a087d3c58b7087a73
BLAKE2b-256 checksum
How to use checksums
6f7cbaba4668dedd14725f4e3c81641bebc152e51d62b2d91e155e069820532a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.2 This release

1 release file

0.2

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page