"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "docs/users_guide/flowControl.rst" between
cheetah3-3.1.0.tar.gz and cheetah3-3.2.0.tar.gz

About: Cheetah3 is a template engine and code generation tool for e.g. for Web development or Java, SQL, LaTeX, form email ... (written in Python).

flowControl.rst  (cheetah3-3.1.0):flowControl.rst  (cheetah3-3.2.0)
Flow Control Flow Control
============ ============
(flowControl)
#for ... #end for #for ... #end for
----------------- -----------------
(flowControl.for)
Syntax: Syntax:
:: ::
#for $var in EXPR #for $var in EXPR
#end for #end for
The {#for} directive iterates through a sequence. The syntax is the The {#for} directive iterates through a sequence. The syntax is the
same as Python, but remember the {$} before variables. same as Python, but remember the {$} before variables.
skipping to change at line 84 skipping to change at line 80
Although to just put a separator between strings, you don't need a Although to just put a separator between strings, you don't need a
for loop: for loop:
:: ::
#echo ', '.join($names) #echo ', '.join($names)
#repeat ... #end repeat #repeat ... #end repeat
----------------------- -----------------------
(flowControl.repeat)
Syntax: Syntax:
:: ::
#repeat EXPR #repeat EXPR
#end repeat #end repeat
Do something a certain number of times. The argument may be any Do something a certain number of times. The argument may be any
numeric expression. If it's zero or negative, the loop will execute numeric expression. If it's zero or negative, the loop will execute
zero times. zero times.
skipping to change at line 129 skipping to change at line 123
#end for #end for
A previous implementation used a local variable {$i} as the repeat A previous implementation used a local variable {$i} as the repeat
counter. However, this prevented instances of {#repeat} from being counter. However, this prevented instances of {#repeat} from being
nested. The current implementation does not have this problem as it nested. The current implementation does not have this problem as it
uses a new local variable for every instance of {#repeat}. uses a new local variable for every instance of {#repeat}.
#while ... #end while #while ... #end while
--------------------- ---------------------
(flowControl.while)
Syntax: Syntax:
:: ::
#while EXPR #while EXPR
#end while #end while
{#while} is the same as Python's {while} statement. It may be {#while} is the same as Python's {while} statement. It may be
followed by any boolean expression: followed by any boolean expression:
skipping to change at line 153 skipping to change at line 145
#while $someCondition('arg1', $arg2) #while $someCondition('arg1', $arg2)
The condition is true. The condition is true.
#end while #end while
Be careful not to create an infinite loop. {#while 1} will loop Be careful not to create an infinite loop. {#while 1} will loop
until the computer runs out of memory. until the computer runs out of memory.
#if ... #else if ... #else ... #end if #if ... #else if ... #else ... #end if
-------------------------------------- --------------------------------------
(flowControl.if)
Syntax: Syntax:
:: ::
#if EXPR #if EXPR
#else if EXPR #else if EXPR
#elif EXPR #elif EXPR
#else #else
#end if #end if
skipping to change at line 220 skipping to change at line 210
#else #else
<p> Sorry, the search did not find any people. </p> <p> Sorry, the search did not find any people. </p>
#end if #end if
See section output.oneLineIf for the one-line {#if} directive, See section output.oneLineIf for the one-line {#if} directive,
which is equivalent to Perl's and C's {?:} operator. which is equivalent to Perl's and C's {?:} operator.
#unless ... #end unless #unless ... #end unless
----------------------- -----------------------
(flowControl.unless)
Syntax: Syntax:
:: ::
#unless EXPR #unless EXPR
#end unless #end unless
{#unless} is the opposite of {#if}: the text is executed if the {#unless} is the opposite of {#if}: the text is executed if the
condition is { false}. Sometimes this is more convenient. {#unless condition is { false}. Sometimes this is more convenient. {#unless
EXPR} is equivalent to {#if not (EXPR)}. EXPR} is equivalent to {#if not (EXPR)}.
skipping to change at line 247 skipping to change at line 235
'E's expired and gone to meet 'is maker! ... 'E's expired and gone to meet 'is maker! ...
THIS IS AN EX-PARROT!! THIS IS AN EX-PARROT!!
#end unless #end unless
You cannot use {#else if} or {#else} inside an {#unless} construct. You cannot use {#else if} or {#else} inside an {#unless} construct.
If you need those, use {#if} instead. If you need those, use {#if} instead.
#break and #continue #break and #continue
-------------------- --------------------
(flowControl.break)
Syntax: Syntax:
:: ::
#break #break
#continue #continue
These directives are used as in Python. {#break} will exit a {#for} These directives are used as in Python. {#break} will exit a {#for}
loop prematurely, while {#continue} will immediately jump to the loop prematurely, while {#continue} will immediately jump to the
next iteration in the {#for} loop. next iteration in the {#for} loop.
skipping to change at line 286 skipping to change at line 272
#for $name in $names #for $name in $names
#if $name == 'Joe' #if $name == 'Joe'
#break #break
#end if #end if
$name - #slurp $name - #slurp
#end for #end for
#pass #pass
----- -----
(flowControl.pass)
Syntax: Syntax:
:: ::
#pass #pass
The {#pass} directive is identical to Python {pass} statement: it The {#pass} directive is identical to Python {pass} statement: it
does nothing. It can be used when a statement is required does nothing. It can be used when a statement is required
syntactically but the program requires no action. syntactically but the program requires no action.
skipping to change at line 315 skipping to change at line 299
#pass #pass
#elif $B #elif $B
do something do something
#else #else
do something do something
#end if #end if
#stop #stop
----- -----
(flowControl.stop)
Syntax: Syntax:
:: ::
#stop #stop
The {#stop} directive is used to stop processing of a template at a The {#stop} directive is used to stop processing of a template at a
certain point. The output will show { only} what has been processed certain point. The output will show { only} what has been processed
up to that point. up to that point.
skipping to change at line 373 skipping to change at line 355
:: ::
A cat A cat
sat on a mat sat on a mat
in a flat. in a flat.
#return #return
------- -------
(flowControl.return)
Syntax: Syntax:
:: ::
#return #return
This is used as in Python. {#return} will exit the current method This is used as in Python. {#return} will exit the current method
with a default return value of {None} or the value specified. It with a default return value of {None} or the value specified. It
may be used only inside a {#def} or a {#block}. may be used only inside a {#def} or a {#block}.
 End of changes. 10 change blocks. 
20 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)