Zen: blocks

Back to Zen homepage

prev next

1. save contents

The contents can be saved into variable, possibly process it further and use later. The syntax to achieve it is the save into pair demonstrated below.
{save} <u>underlined</u> <i>italic</i> {into $demo} {=strtoupper($demo)}



2. include another file

Lets have a file bold.zen with following contents <b>{=html:$BOLD}</b> We can define the required $BOLD variable and include it in our zen template using include or require keyword:
{$BOLD = $demo} {include "bold.zen"}


underlined italic

3. local context

The approach above is easy to implement and easily maintainable with single level inheritance, but with more complex structure, it may be difficult not to get lost in monolitic global variables structure. In the example below we call bold.zen with local $BOLD variable that does not affect our previously assigned $BOLD variable in our context:
{=html:zen("bold.zen",["BOLD"=>"hello world"])} {=$BOLD}


hello world
<u>underlined</u> <i>italic</i>