From f2cfc12d7f3a7910224a384f01dd9e47c27daa89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 2 May 2019 11:36:36 +0200 Subject: [PATCH] add doc for chill_print_or_message --- .../user-interface/layout-template-usage.rst | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/source/development/user-interface/layout-template-usage.rst b/source/development/user-interface/layout-template-usage.rst index e67221e75..14404b907 100644 --- a/source/development/user-interface/layout-template-usage.rst +++ b/source/development/user-interface/layout-template-usage.rst @@ -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") }} + + + {{ ""|chill_print_or_message("No message")}} + + + {{ "This is a comment\n with multiples lines"|chill_print_or_message("No comment", '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', {