If you use Cheetah, please support the project and register by clicking here:


9.9 #return

Syntax:

#return

This is used as in Python. #return will exit the current method with a default return value of None or the value specified. It may be used only inside a #def or a #block.

Note that #return is different from the #stop directive, which returns the sum of all text output from the method in which it is called. The following examples illustrate this point:

1
$test[1]
3
#def test
1.5
#if 1
#return '123'
#else
99999
#end if
#end def

will produce

1
2
3

while

1
$test
3
#def test
1.5
#if 1
#stop
#else
99999
#end if
#end def

will produce

1
1.5
3

If you use Cheetah, please support the project and register by clicking here: