Template code Chunk output
{#example_1}
{!-- Including another template is easy!
  --
  --    {.include [filename][#snippetRef]}
  --
  -- You must provide either the filename or the #snippet name,
  -- or both for a fully qualified snippet reference.
  --
  -- If the included template contains any tags, they
  -- will be evaluated.
  --
  -- This example includes a "local" snippet, eg defined in this
  -- same file (so the filename can be safely omitted):
  --    themes/examples/include.chtml
  --
  --}
{.include #example_2}
{#}
Theme theme = new Theme("examples");
 
// fetch template snippet from themes/examples/include.chtml
Chunk html = theme.makeChunk("include#example_1");
 
html.set("name","Penelope");

StreamWriter out = getStreamWriter();
html.render( out );
Hello Include.  Your name is Penelope.


Hello Include. Your name is Penelope.
Template code Chunk output
{#example_2}
Hello Include.  Your name is {$name}.
{#}
//...
Hello Include.  Your name is {$name}.

Hello Include. Your name is {$name}.
Template code Chunk output
{!-- Include a whole template file from this theme (minus any snippets).
  --
  -- This grabs the contents of the main template defined in:
  --   themes/examples/lorem_ipsum.chtml
  --
  -- Leave off the .chtml filename extension or the include will fail.
  --}
<p>
{.include lorem_ipsum}
</p>
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();
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

</p>

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Template code Chunk output
{!-- Include a snippet defined inside another file in this theme:
  --   themes/examples/indent.chtml
  -- 
  -- You must leave out the .chtml filename extension.
  --}
<pre>
{.include indent#ascii_earth}
</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();
<pre>
               ,,ggddY"""Ybbgg,,
          ,agd888b,_ "Y8, ___`""Ybga,
       ,gdP""88888888baa,.""8b    "888g,
     ,dP"     ]888888888P'  "Y     `888Yb,
   ,dP"      ,88888888P"  db,       "8P""Yb,
  ,8"       ,888888888b, d8888a           "8,
 ,8'        d88888888888,88P"' a,          `8,
,8'         88888888888888PP"  ""           `8,
d'          I88888888888P"                   `b
8           `8"88P""Y8P'                      8
8            Y 8[  _ "                        8
8              "Y8d8b  "Y a                   8
8                 `""8d,   __                 8
Y,                    `"8bd888b,             ,P
`8,                     ,d8888888baaa       ,8'
 `8,                    888888888888'      ,8'
  `8a                   "8888888888I      a8'
   `Yba                  `Y8888888P'    adP'
     "Yba                 `888888P'   adY"
       `"Yba,             d8888P" ,adP"'  Normand Veilleux
          `"Y8baa,      ,d888P,ad8P"'           from
               ``""YYba8888P""''          Spaceship Earth

</pre>

               ,,ggddY"""Ybbgg,,
          ,agd888b,_ "Y8, ___`""Ybga,
       ,gdP""88888888baa,.""8b    "888g,
     ,dP"     ]888888888P'  "Y     `888Yb,
   ,dP"      ,88888888P"  db,       "8P""Yb,
  ,8"       ,888888888b, d8888a           "8,
 ,8'        d88888888888,88P"' a,          `8,
,8'         88888888888888PP"  ""           `8,
d'          I88888888888P"                   `b
8           `8"88P""Y8P'                      8
8            Y 8[  _ "                        8
8              "Y8d8b  "Y a                   8
8                 `""8d,   __                 8
Y,                    `"8bd888b,             ,P
`8,                     ,d8888888baaa       ,8'
 `8,                    888888888888'      ,8'
  `8a                   "8888888888I      a8'
   `Yba                  `Y8888888P'    adP'
     "Yba                 `888888P'   adY"
       `"Yba,             d8888P" ,adP"'  Normand Veilleux
          `"Y8baa,      ,d888P,ad8P"'           from
               ``""YYba8888P""''          Spaceship Earth