跳转到主要内容

一个接受多个模板名称的 `{% include %}` 版本。

项目描述

一个接受多个模板名称的 `{% include %}` 版本。

用法

将 `multiple_include` 添加到 `INSTALLED_APPS`。

然后,在您的模板中

{% load multiple_include %}

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

这个模板标签将包含列表中第一个存在的模板。这允许更有趣的使用

{% load multiple_include %}

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

注意:为了更干净的字符串连接,您可以使用随 `Django Basic Apps` 一起提供的 `capture` 标签

在您的设置中

INSTALLED_APPS += ('basic.tools')

模板

{% load multiple_include capture %}

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

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

项目详情


下载文件

下载适合您平台文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源分发

django-multiple-include-0.0.1.tar.gz (6.5 kB 查看哈希值)

上传时间

由以下支持