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" %}
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-multiple-include-0.0.1.tar.gz.
File metadata
- Download URL: django-multiple-include-0.0.1.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
272208fe8f8d7247f4fffc81a3f924424daf93093999244ccd4f0b91ff89ef2c
|
|
| MD5 |
a13ba864e5eb1855bd44365cdb3d9a6a
|
|
| BLAKE2b-256 |
b02730f0c6a2f80f85ac7962471ba88e49f32e66013aa72121147ca785207644
|