Return Command

The Return command allows the execution of the current template, macro, or section to be cut short, optionally returning a value which will override any output being generated by the code being returned from.

There is just one command in the Return family - the Return command itself. It consists of the command, optionally followed by an expression.

For example:

{ macro test() }…
this is a macro
{ return }…
you don't see this!
{ endmacro }…
 
{ test() }

this is a macro

The code above cuts the macro in half, so that the second part is never reached. The first part of the macro's contents is returned as usual. However, this can be overridden:

{ macro test() }…
this is a macro
{ return "bye" }…
you don't see this!
{ endmacro }…
 
{ test() }

bye

In this second example, the macro's output has been replaced by the value supplied to the Return command.

Return commands can appear within other command structures, and within included files, and always apply to the innermost template file, macro, or section that the command is placed into.

ptpscript/commands/return.txt · Last modified: 2007/01/24 10:15
 
 
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki