Latte include macros behavior
- paolo
- Member | 15
In order to better understand the way the different include macros work in latte, I wrote a simple test:
include.latte:
{block content}
<h2>BEGIN (include.latte) block content</h2>
<h3>BEGIN (include.latte) include 'blockAndOutside.latte'</h3>
{include 'blockAndOutside.latte'}
<h3>END (include.latte) include 'blockAndOutside.latte'</h3>
<h3>BEGIN (include.latte) includeblock 'blockAndOutside.latte'</h2>
{includeblock 'blockAndOutside.latte'}
<h3>END (include.latte) includeblock 'blockAndOutside.latte'</h3>
<h3>BEGIN (include.latte) include #test</h2>
{include #test}
<h3>END (include.latte) include #test</h3>
<h3>BEGIN (include.latte) include 'define.latte'</h2>
{include 'define.latte'}
<h3>END (include.latte) include 'define.latte'</h3>
<block definetest></block>
<h3>BEGIN (include.latte) include #definetest if set</h2>
{ifset #definetest}
{include #definetest}
{else}
<p>(include.latte) block 'definetest' not defined</p>
{/ifset}
<h3>END (include.latte) include #definetest if set</h3>
<h2>END (include.latte) block content</h2>
{/block}
blockAndOutside.latte:
<p>(blockAndOutside.latte) before block test</p>
{block test}
<p>(blockAndOutside.latte) block test</p>
{/block}
<p>(blockAndOutside.latte) after block test</p>
define.latte:
{define definetest}
<p>(define.latte) block definetest</p>
{/define}
The output is:
BEGIN (include.latte) block content
BEGIN (include.latte) include ‘blockAndOutside.latte’
(blockAndOutside.latte) before block test
(blockAndOutside.latte) block test
(blockAndOutside.latte) after block test
END (include.latte) include ‘blockAndOutside.latte’
BEGIN (include.latte) includeblock ‘blockAndOutside.latte’
(blockAndOutside.latte) before block test
(blockAndOutside.latte) block test
(blockAndOutside.latte) after block test
END (include.latte) includeblock ‘blockAndOutside.latte’
BEGIN (include.latte) include #test
(blockAndOutside.latte) block test
END (include.latte) include #test
BEGIN (include.latte) include ‘define.latte’
END (include.latte) include ‘define.latte’
BEGIN (include.latte) include #definetest if set
(include.latte) block ‘definetest’ not defined
END (include.latte) include #definetest if set
END (include.latte) block content
I expected:
- that with ‘includeblock’ only blocks where included, and not the text outside blocks
- that with ‘define’ the defined block could be rendered
with
{include #blockname}
so the questions are:
- in what ‘includeblock’ differs from ‘include’, and how it is meant to be used?
- how ‘define’ works and how it is meant to be used?