Skip to content

Commit

Permalink
Added twig translations filters.
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed May 19, 2015
1 parent 8089cee commit deb0d42
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion themes/using_twig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,36 @@ Use them with the *pipe* syntax, eg. ``nodeSource|next``.
* ``lastSibling``: shortcut for ``$source->getHandler()->getLastSibling()``
* ``parent``: shortcut for ``$source->getHandler()->getParent()``
* ``parents``: shortcut for ``$source->getHandler()->getParents()``
* ``tags``: shortcut for ``$source->getHandler()->getTags()``

Documents filters
^^^^^^^^^^^^^^^^^

These following Twig filters will only work with ``Documents`` entities.
These following Twig filters will only work with ``Document`` entities.
Use them with the *pipe* syntax, eg. ``document|display``.

* ``url``: shortcut for ``$document->getViewer()->getDocumentUrlByArray()``
* ``display``: shortcut for ``$document->getViewer()->getDocumentByArray()``

Translations filters
^^^^^^^^^^^^^^^^^^^^

These following Twig filters will only work with ``Translation`` entities.
Use them with the *pipe* syntax, eg. ``translation|menu``.

* ``menu``: shortcut for ``$translation->getViewer()->getTranslationMenuAssignation()``. This
filter returns some useful informations about current page available languages and their
urls. See `getTranslationMenuAssignation method definition <http://api.roadiz.io/RZ/Roadiz/Core/Viewers/TranslationViewer.html#method_getTranslationMenuAssignation>`_.
You do not have to pass it the current request object as the filter will grab it
for you. But you can specify if you want *absolute* urls or not.


Standard filters and extensions are also available:

* ``{{ path('myRoute') }}``: for generating static routes Url.
* ``truncate`` and ``wordwrap`` which are parts of the `Text Extension <http://twig.sensiolabs.org/doc/extensions/text.html>`_ .


Create your own Twig filters
----------------------------

Expand Down

0 comments on commit deb0d42

Please sign in to comment.