<commit_before>==================
Django FlatContent
==================

.. image:: https://travis-ci.org/orcasgit/django-flatcontent.svg
   :target: https://travis-ci.org/orcasgit/django-flatcontent
   :alt: Travis Status
.. image:: https://codecov.io/gh/orcasgit/django-flatcontent/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/orcasgit/django-flatcontent
   :alt: Coverage Status
.. image:: https://requires.io/github/orcasgit/django-flatcontent/requirements.png?branch=master
   :target: https://requires.io/github/orcasgit/django-flatcontent/requirements/?branch=master
   :alt: Requirements Status

Django FlatContent is intended as a flatpages-like app but for smaller chunks
of content that can be edited in the Django admin.

Features
========

* Simple FlatContent model
* Template tag for pulling FlatContent into templates
* Caching of FlatContent for performance

Installation
============

1. ``pip install flatcontent``.
2. Add ``flatcontent`` to your ``INSTALLED_APPS``.
3. Run the command ``manage.py migrate`` to install the models.

Usage
=====

Once content is available in the `FlatContent` model, it can be accessed via
the templates using the provided template tags::

    {% load flatcontent_tags %}
    <div id="footer">
        {% flatcontent footer %}
    </div>

The above will perform a slug lookup on the text "footer" and return the
content associated with that slug.

You can also put the content into a template variable for passing to other
template tags or filters.  For example, getting the footer and processing the
text through the `textile` filter::

    {% load flatcontent_tags markup %}
    <div id="footer">
        {% flatcontent footer as content %}
        {{ content|textile }}
    </div>
<commit_msg>add docs for template rendering and extra context<commit_after>==================
Django FlatContent
==================

.. image:: https://travis-ci.org/orcasgit/django-flatcontent.svg
   :target: https://travis-ci.org/orcasgit/django-flatcontent
   :alt: Travis Status
.. image:: https://codecov.io/gh/orcasgit/django-flatcontent/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/orcasgit/django-flatcontent
   :alt: Coverage Status
.. image:: https://requires.io/github/orcasgit/django-flatcontent/requirements.png?branch=master
   :target: https://requires.io/github/orcasgit/django-flatcontent/requirements/?branch=master
   :alt: Requirements Status

Django FlatContent is intended as a flatpages-like app but for smaller chunks
of content that can be edited in the Django admin.

Features
========

* Simple FlatContent model
* Template tag for pulling FlatContent into templates
* Template rendering of flatcontent items
* Caching of FlatContent for performance

Installation
============

1. ``pip install flatcontent``.
2. Add ``flatcontent`` to your ``INSTALLED_APPS``.
3. Run the command ``manage.py migrate`` to install the models.

Usage
=====

Once content is available in the `FlatContent` model, it can be accessed via
the templates using the provided template tags::

    {% load flatcontent_tags %}
    <div id="footer">
        {% flatcontent footer %}
    </div>

The above will perform a slug lookup on the text "footer" and return the
content associated with that slug.

You can also put the content into a template variable for passing to other
template tags or filters.  For example, getting the footer and processing the
text through the `textile` filter::

    {% load flatcontent_tags markup %}
    <div id="footer">
        {% flatcontent footer as content %}
        {{ content|textile }}
    </div>

Add context for flatcontent rendering using the `with` keyword. For example, if
you have a flatcontent item with the content `Homer {{ last_name }}`, you could
use the following in your django template to achieve `Homer Simpson` as the
output::

    {% load flatcontent_tags %}
    {% flatcontent homer-simpson with last_name='Simpson' %}

{'fraction_non_alphanumeric': 0.1230379746835443, 'fraction_numerical': 0.0015189873417721519, 'mean_word_length': 4.198684210526316, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5465593', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1069, 'n_words': 400}