gregcoleinfo edited this page Oct 5, 2012 · 5 revisions

Partial templates separate out re-usable and repeatable blocks of code into their own files. They sit within the /templates/partials folder. Partials are similar to the idea of linking to .css or .js files in the head of an html document, but a partial can be any code used with the Stacey templating language.

Partials do not need to be .html files. Stacey should recognize the following formats: .html, .json, .xml, .atom, .rss, .rdf & .txt

Including a partial

To include a partial, use the following code

{% include 'partials/PathToFile' %}

PathToFile can be a path to any file inside a folder structure within /templates/partials. You can have multiple partials with the same name if they are located in different folders.

Partial Nesting

Partials references can also be nested within other partials. The following is part of the default media.html partial that checks for various page assets and includes other partials.

This excerpt of code is found in /templates/partials/assets/media.html

{% if page.images %}
  {% include 'partials/assets/images.html' %}
{% endif %}

{% if %}
  {% include 'partials/assets/video.html' %}
{% endif %}