Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
133 lines (74 sloc) 2.6 KB

Writing Content

Content files consists of two sections: Meta data and content. The meta data get parsed by YAML, the content according to the file extension.

The meta data block comes first and is divided by from the content block by two or more blank lines. If you won't set any meta data your content file has to start with two or more blank lines.

# content/hello-world.rst
title: hello-world
a: foo
b: bar

Hello World!

Lorem Ipsum

The parsed flamingo.core.data_model.Content object will look like this:

In [1]: content['title']
Out[1]: 'hello-world'

In [2]: content['a']
Out[2]: 'foo'

In [3]: content['content_title']
Out[3]: 'Hello World!'

In [4]: content['content_body']
Out[4]: '<p>Lorem Ipsum</p>'

Reserved Attributes

Using Jinja2 Syntax

When settings.PRE_RENDER_CONTENT is enabled, every content file can be a template:

# content/test.html
title: test

<h1>List of all Contents with the tag "foo"</h1>

    {% for content in context.contents.filter(tags__contains='foo') %}
        <a href="{{ content.url }}">{{ content.title }}</a>
    {% endfor %}

Generating links

# content/link.html
title: link

<h1>Link to first Content with the tag "foo"</h1>

{{ link('content/test.html', 'Test document') }}
You can’t perform that action at this time.