Template code Chunk output
{!-- Any piece of the template encased in {.literal}{/literal} tags
  -- will not be interpreted by the template engine.
  --
  -- The encasing tags are preserved so that the block will survive
  -- intact even after multiple passes through the engine.
  --
  -- So, hiding the {.literal} tags in HTML comments is recommended.
  --
  -- NB: Literal tags may not be nested.
  --}

<h2>Inside the literal jail:</h2>

<!-- {.literal} -->

<pre style="border: 2px dotted blue; background-color:lightblue;">

{$these:tags} {$will|onempty(not be processed)}

{!-- comments will pass through to final output --}
{.tagStack}
{.exec MY_TEMPLATE}{/exec}

{.loop in $list as $item}{$item}{.onEmpty}Empty list!{/loop}

</pre>

<!-- {/literal} -->



<hr/>



<h2>Now let's see the same code outside the literal jail:</h2>

<pre style="border: 2px dotted blue; background-color:lightblue;">

{$these:tags} {$will|onempty(not be processed)}

{!-- comments will pass through to final output --}
{.tagStack}
{.exec MY_TEMPLATE}{/exec}

{.loop in $list as $item}{$item}{.onEmpty}Empty list!{/loop}

</pre>

Theme theme = new Theme();

// fetch template from themes/example.chtml
Chunk html = theme.makeChunk("example");

// Insert business logic here.
// Normally you write a lot of html.set("this","that") calls here.

StreamWriter out = getStreamWriter();
html.render( out );

///// or, return the rendered template as a string
// return html.toString();

<h2>Inside the literal jail:</h2>

<!-- {.literal} -->

<pre style="border: 2px dotted blue; background-color:lightblue;">

{$these:tags} {$will|onempty(not be processed)}

{!-- comments will pass through to final output --}
{.tagStack}
{.exec MY_TEMPLATE}{/exec}

{.loop in $list as $item}{$item}{.onEmpty}Empty list!{/loop}

</pre>

<!-- {/literal} -->



<hr/>



<h2>Now let's see the same code outside the literal jail:</h2>

<pre style="border: 2px dotted blue; background-color:lightblue;">

tags not be processed

Available tags:
$now

[chtml template 'MY_TEMPLATE' not found]<!-- looked in [themes/2.4/examples/MY_TEMPLATE.chtml] -->
Empty list!
</pre>


Inside the literal jail:


{$these:tags} {$will|onempty(not be processed)}

{!-- comments will pass through to final output --}
{.tagStack}
{.exec MY_TEMPLATE}{/exec}

{.loop in $list as $item}{$item}{.onEmpty}Empty list!{/loop}


Now let's see the same code outside the literal jail:


tags not be processed

Available tags:
$now

[chtml template 'MY_TEMPLATE' not found]
Empty list!