How to include file with latte block definitions

6 years ago

duke
Member | 650
+
0
-

I'd like to be able to easily include files containing block definitions from my latte files.
E.g.:

{* load the definitions of #flashes, and #flash blocks *}
{include '../@flashes.latte'}

{* override the flashes block *}
{block flashes}
{include parent}
{if $_control['myForm']->errors}
{foreach $_control['myForm']->errors as $error}
    {include flash type => error, message => $error}
{/foreach}
{/if}
{/block}

{block content}
    {* place the flashes block *}
    {include flashes}
    ...

Neither {include} nor {includeblock} macro will work like that currently. What works is to create specific layout file with these definitions (but again cannot use another {include} or {includblock} macro from within the layout file) and specify this layout using {extend} macro. This is however not ideal, as I may need different layout files for different templates, and this solution would then lead to redundancies.

What is the recommended solution for this?