From: Mark Story Date: Thu, 31 Mar 2011 01:55:15 +0000 (-0400) Subject: Adding a bit of documentation for whitespace trimming. X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=8f158bdda930bf2541c6e746fe82b97481492bc2;p=konrad%2Ftwig.git Adding a bit of documentation for whitespace trimming. --- diff --git a/doc/templates.rst b/doc/templates.rst index 5c21473..1869f63 100644 --- a/doc/templates.rst +++ b/doc/templates.rst @@ -160,6 +160,26 @@ Use the ``spaceless`` tag to remove whitespace between HTML tags: {# output will be
foo
#} +In addition to the spaceless tag you can also control whitespace on a per tag +level. By using the whitespace control modifier on your tags you can trim +leading and or trailing horizontal whitespace from any tag type: + +.. code-block:: jinja + + {#- No leading/trailing whitespace -#} + {%- if condition %-} + {{- value -}} + {%- endif -%} + +The above sample shows the default whitespace control modifier, and how you can +use it to remove whitespace around tags. Only horizontal space will be removed +any vertical space (newlines) will need to be removed with the +``spaceless`` tag. + +..versionadded:: 1.1 + + Tag level whitespace control was added in 1.1 + Escaping --------