add doc for chill_print_or_message

This commit is contained in:
Julien Fastré 2019-05-02 11:36:36 +02:00
parent dec55131df
commit f2cfc12d7f

View File

@ -14,6 +14,38 @@ We recommand the use of the existing layouts to ensure the consistency of the de
The layouts are twig templates.
Twig templating helper
======================
`chill_print_or_message`
------------------------
Print a value or use a default template if the value is empty.
The template can be customized.
Two default templates are registered:
- :code:`default`, do not decorate the value ;
- :code:`blockquote`: wrap the value into a blockquote if exists
.. code-block:: html+twig
{{ "This is a message"|chill_print_or_message("No message") }}
<!-- will print "This is a message" -->
{{ ""|chill_print_or_message("No message")}}
<!-- will print <span class="chill-no-data-statement">No message</span> -->
{{ "This is a comment\n with multiples lines"|chill_print_or_message("No comment", 'blockquote') }}
<!-- will print <blockquote class="chill-user-quote">This is a comment<br/>with multiples lines</blockquote> -->
When customizing the template, two arguments are passed to the template:
- :code:`value`: the actual value ;
- :code:`message`: the message, given as argument
Organisation of the layouts
===========================
@ -159,7 +191,7 @@ The accepted parameters are :
Usage :
.. code-block:: html+jinja2
.. code-block:: html+twig
{{ include('ChillMainBundle:Util:confirmation_template.html.twig',
{