Mercurial > genshi > genshi-test
diff doc/text-templates.txt @ 511:1a29617a5d87 stable-0.4.x
Ported [611:614] to 0.4.x branch.
author | cmlenz |
---|---|
date | Wed, 06 Jun 2007 11:18:46 +0000 |
parents | ff7c72b52fb2 |
children |
line wrap: on
line diff
--- a/doc/text-templates.txt +++ b/doc/text-templates.txt @@ -57,7 +57,9 @@ ``#if`` --------- -The content is only rendered if the expression evaluates to a truth value:: +The content is only rendered if the expression evaluates to a truth value: + +.. code-block:: genshitext #if foo ${bar} @@ -82,7 +84,9 @@ no ``#when`` branch matches, the ``#otherwise`` branch is be rendered. If the ``#choose`` directive has no argument the nested ``#when`` directives -will be tested for truth:: +will be tested for truth: + +.. code-block:: genshitext The answer is: #choose @@ -103,7 +107,9 @@ 1 If the ``#choose`` does have an argument, the nested ``#when`` directives will -be tested for equality to the parent ``#choose`` value:: +be tested for equality to the parent ``#choose`` value: + +.. code-block:: genshitext The answer is: #choose 1 @@ -132,7 +138,9 @@ ``#for`` ---------- -The content is repeated for every item in an iterable:: +The content is repeated for every item in an iterable: + +.. code-block:: genshitext Your items: #for item in items @@ -158,7 +166,9 @@ The ``#def`` directive can be used to create macros, i.e. snippets of template text that have a name and optionally some parameters, and that can be inserted -in other places:: +in other places: + +.. code-block:: genshitext #def greeting(name) Hello, ${name}! @@ -172,7 +182,9 @@ Hello, everyone else! If a macro doesn't require parameters, it can be defined as well as called -without the parenthesis. For example:: +without the parenthesis. For example: + +.. code-block:: genshitext #def greeting Hello, world! @@ -198,7 +210,9 @@ than once, and that actually results in a database query, assigning the results to a variable using this directive would probably help. -For example:: +For example: + +.. code-block:: genshitext Magic numbers! #with y=7; z=x+10