Cannot redeclare block when using condition in {embed}
Version: 2.9.2, 2.10.0
Bug Description
Parser throws: Latte\CompileException: Cannot redeclare block 'someBlock' in ...
Steps To Reproduce
Run Latte with this code in a template file:
{define aaa}
<span>{block someBlock}{/block}</span>
{/define}
{embed aaa}
{if 3 === 4}
{block someBlock}a{/block}
{else}
{block someBlock}b{/block}
{/if}
{/embed}
Expected Behavior
Output <span>b</span>
Note that I can't wrap {if} with {block} as I define multiple blocks so it would lead to repeating conditional logic in every block.
This way the blocks do not work, see the documentation https://latte.nette.org/cs/template-inheritance#toc-layoutova-dedicnost:~:text=bez%20ohledu%20na%20to
@dg Why is this actually? Is it just "not implemented" or is it conceptually impossible – something like want to run TS code directly in browser?
It is conceptually impossible. It is something like
class Foo
{
if (3 === 4) {
function someBlock()
{ return 'a' }
} else {
function someBlock()
{ return 'b' }
}
}