Templatetags — django-inline-media v1.0a documentation

### Navigation

- index
- next |
- previous |
- django-inline-media v1.0a documentation »

# Templatetags

Django-inline-media comes with two filters and one tag:

> - filter `render_inlines`
> - filter `extract_inlines`
> - tag `get_inline_types`

To use any of them in your templates you first need to load them:

    {% load inlines %}

## Filter: render_inlines

Renders inlines in a text by passing them through inline templates.

Syntax:

    {{ <field>|render_inlines }}

Inline Syntax (singular):

    <inline type="<app_name>.<model_name>" id="<id>" class="<cssclass>" />

Inline Syntax (plural):

    <inline type="<app_name>.<model_name>" ids="<id>, <id>, <id>" />

An inline template will be used to render the inline. Templates will be located in the following maner:
  `inline_media/<app_name>_<model_name>.html`
The template will be passed the following context:
  - object: an object for the corresponding passed id, or
  - object_list: a list of objects for the corresponding ids.

It would be wise to anticipate both object_list and object unless you know for sure one or the other will only be present.

Example usage:

    {{ object.body|render_inlines }}

## Filter: extract_inlines

Extract inlines from a text.

Syntax:

    {{ <field>|extract_inlines }}

Example usage:

    {% for inline in object.body|extract_inlines %}
      {% ifequal inline.content_type "inline_media.picture" %}
        {% include "inline_media/inline_media_picture.html" with object=inline.object class=inline.class %}
      {% endifequal %}
    {% endfor %}

## Tag: get_inline_types

Gets all inline types.

Syntax:

    {% get_inline_types as [var_name] %}

Example usage:

    {% get_inline_types as inline_list %}

### Navigation

- index
- next |
- previous |
- django-inline-media v1.0a documentation »