Template Tags

Collections

The collection template tags are automatically included as builtins if philo is an installed app.

templatetag collections.membersof

Given a collection and a content type, sets the results of collection.members.with_model as a variable in the context.

Usage:

{% membersof <collection> with <app_label>.<model_name> as <var> %}

Containers

The container template tags are automatically included as builtins if philo is an installed app.

templatetag containers.container

If a template using this tag is used to render a Page, that Page will have associated content which can be set in the admin interface. If a content type is referenced, then a ContentReference object will be created; otherwise, a Contentlet object will be created.

Usage:

{% container <name> [[references <app_label>.<model_name>] as <variable>] %}

Embedding

The embed template tags are automatically included as builtins if philo is an installed app.

templatetag embed.embed

The {% embed %} tag can be used in two ways.

First, to set which template will be used to render a particular model. This declaration can be placed in a base template and will propagate into all templates that extend that template.

Syntax:

{% embed <app_label>.<model_name> with <template> %}

Second, to embed a specific model instance in the document with a template specified earlier in the template or in a parent template using the first syntax. The instance can be specified as a content type and pk or as a context variable. Any kwargs provided will be passed into the context of the template.

Syntax:

{% embed (<app_label>.<model_name> <object_pk> || <instance>) [<argname>=<value> ...] %}

Nodes

The node template tags are automatically included as builtins if philo is an installed app.

templatetag nodes.node_url

The node_url tag allows access to View.reverse() from a template for a Node. By default, the Node that is used for the call is pulled from the context variable node; however, this can be overridden with the [for <node>] option.

Usage:

{% node_url [for <node>] [as <var>] %}
{% node_url with <obj> [for <node>] [as <var>] %}
{% node_url <view_name> [<arg1> [<arg2> ...] ] [for <node>] [as <var>] %}
{% node_url <view_name> [<key1>=<value1> [<key2>=<value2> ...] ] [for <node>] [as <var>] %}

String inclusion

templatetag include_string.include_string

Include a flat string by interpreting it as a template. The compiled template will be rendered with the current context.

Usage:

{% include_string <template_code> %}

Project Versions

Table Of Contents

Previous topic

Utilities

Next topic

Forms

This Page