Skip to main content
Help us improve Python packaging – donate today!

A version of ``{% include %}`` that accepts multiple template names.

Project Description

A version of {% include %} that accepts multiple template names.

Usage

Add multiple_include to INSTALLED_APPS.

Then, in your template:

{% load multiple_include %}

{% multiple_include "template1.html" "template2.html" "template2.html" with object=item %}

The templatetag will include the first existing template from the list. This allows more interesting uses as:

{% load multiple_include %}

{% with "story_"|add:object.category_slug|add:".html" as category_template %}
{% multiple_include category_template "news/story_default.html" %}
{% endwith %}

Note: For a cleaner string concatenation, you can use the capture tag shipped with Django Basic Apps:

In your settings:

INSTALLED_APPS += ('basic.tools')

Template:

{% load multiple_include capture %}

{% capture as category_template %}
    story_{{ object.category_slug}}.html
{% endcapture %}

{% multiple_include category_template "news/story_default.html" %}

Release history Release notifications

This version
History Node

0.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-multiple-include-0.0.1.tar.gz (6.5 kB) Copy SHA256 hash SHA256 Source None May 13, 2013

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page