.. include:: _include.rst .. highlight:: html+jinja .. _templates_include: ####################### Include other tempates ####################### A very useful feature of |asa2|'s template syntax is the :ref:`template_tags_include` tag. It allows you to include one or more templates in another. This helps us keeping our template code clean and separated. For example you can create template snippets, like for galleries, price information or different rating styles and inlcude these snippets in your main templates. The include syntax is easy: .. code:: {% include "template_name" %} You can also use the **template ID** which makes the template name change safe: .. code:: {% include "2" %} .. note:: When using the template name it has to match exactly! .. note:: Nested includes are not possible. ******* Example ******* If you have different rating stars designs, you can prepare a template snippet for every one. Template name ``rating_stars_blue``: .. code:: Template name ``rating_stars_red``: .. code:: Template name ``rating_stars_green``: .. code:: Now in your main template you can include one of them. Let's say for your new template you want to use the blue ratings stars, use this ``include`` statement: .. code::

Your template code ...

{% include "rating_stars_blue" %}