Package: armstrong.core.arm_layout
Provides layout and templating features for use in Armstrong and Django
projects.arm_layoutprovides tools to help streamline displaying content
and excels at rendering standardized, model-specific templates that are easy
to share or overwrite to be as general or specific as you need. Render your
model objects wherever you need them in your templates without worrying about
object specifics or view logic.UsageCheat sheet{% load layout_helpers %}

{% render_model model_obj "template_name" %}

<!-- otherwise render_model behaves exactly like {% include ... %} -->
{% render_model model_obj "template_name" with additional="data" %}
{% render_model model_obj "template_name" with isolated="context" only %}

<!-- shortcut to call render_model on a list of model objects -->
{% render_list list_of_models "template_name" %}

<!-- or more flexible looping -->
{% render_iter list_of_models %}
    {% render_next "big" %}
    {% render_next "small" %}
    {% render_next "big" %}
    {% render_remainder "small" %}
{% endrender_iter %}In depthTo load the template tags, add the following line (generally at the top of your
template):{% load layout_helpers %}Now you can use therender_modeltemplate tag to display a given model
like this:{% render_model some_model "full_page" %}some_modelis a variable in your template that is a model instance and the
string"full_page"is the name of your “layout”.render_modellooks
for a template namedlayout/<app_label>/<model>/<layout>.htmlto determine
what to use to display your model instance. Going one step further, it is smart
enough to walk through the inheritance of the model to determine if there are
any parent models that have the layout that can be used. For example, ifsome_modelwas an instance ofarmstrong.apps.articles.models.Articlethat inherits fromarmstrong.apps.content.models.Content,render_modellooks for the following templates, in this order:["layout/articles/article/full_page.html",
 "layout/content/content/full_page.html", ]You have access to the entire template context inside thefull_page.htmltemplate. You also have a new variable calledobjectwhich represents the
model instance that you provided torender_model. That variable is only
available inside the layout template and temporarily overrides any other
context variable calledobject. Aside from the flexibility of looking up a
template based on model inheritance, this tag works just like{% include %}.
You can add to the context usingwithextra="param"or isolate the context
usingonly. Oncerender_modelis finished, it restores the original
context.layout_helpersprovides two other helper methods for easily rendering
multiple models without having to manually loop through them. You can render
an entire list of models using the same template:{% render_list list_of_models "preview" %}Or have finer control with a block tag that lets you step through each model
instance specifying the template each time and then rendering all the rest
with a common template:{% render_iter list_of_models %}
    {% render_next "preview" %}
    {% render_next "preview" %}
    {% render_next "preview" %}
    {% render_remainder "headline" %}
{% endrender_iter %}Of course you could do the same thing another way:{% render_list list_of_models[:3] "preview" %}
{% render_list list_of_models[3:] "headline" %}A limitation of these loop helpers is they cannot add or limit the context
usingwithoronlyasrender_modelcan. You could however wrap
the tags in a{% withneed="this"and="that"%} ... {% endwith %}block.
See thewith documentation.Installation & ConfigurationSupports Django 1.3, 1.4, 1.5, 1.6, 1.7 on Python 2.6 and 2.7.pip install armstrong.core.arm_layoutAddarmstrong.core.arm_layoutto yourINSTALLED_APPSOptional Setting:(Used insettings.pyand safe to omit)ARMSTRONG_LAYOUT_BACKEND = "armstrong.core.arm_layout.backends.BasicLayoutBackend"Backends specify how the template tags actually determine template paths.
There are two options–BasicLayoutBackendandModelProvidedLayoutBackend. Basic uses model inheritance as a directory
structure. ModelProvided does the same, but optionally allows a model to
determine its own template lookup. A few model mixins are provided for
common scenarios. Feel free to write your own backend if you need other
functionality.ContributingDevelopment occurs on Github. Participation is welcome!Found a bug? File it onGithub Issues. Include as much detail as you
can and make sure to list the specific component since we use a centralized,
project-wide issue tracker.Testing?pip install toxand runtoxHave code to submit? Fork the repo, consolidate your changes on a topic
branch and create apull request. Thearmstrong.devpackage provides
tools for testing, coverage and South migration as well as making it very
easy to run a full Django environment with this component’s settings.Questions, need help, discussion? Use ourGoogle Groupmailing list.State of ProjectArmstrongis an open-source news platform that is freely available to any
organization. It is the result of a collaboration between theTexas TribuneandThe Center for Investigative Reportingand a grant from theJohn S. and James L. Knight Foundation. Armstrong is available as a
complete bundle and as individual, stand-alone components.