Latte include macros behavior

Notice: This thread is very old.
Member | 15

In order to better understand the way the different include macros work in latte, I wrote a simple test:


{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}
    <p>(include.latte) block 'definetest' not defined</p>
<h3>END (include.latte) include #definetest if set</h3>

<h2>END (include.latte) block content</h2>



<p>(blockAndOutside.latte) before block test</p>
{block test}
<p>(blockAndOutside.latte) block test</p>
<p>(blockAndOutside.latte) after block test</p>


{define definetest}
<p>(define.latte) block definetest</p>

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:

  1. that with ‘includeblock’ only blocks where included, and not the text outside blocks
  2. that with ‘define’ the defined block could be rendered with {include #blockname}

so the questions are:

  1. in what ‘includeblock’ differs from ‘include’, and how it is meant to be used?
  2. how ‘define’ works and how it is meant to be used?