Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot redeclare block when using condition in {embed} #253

Open
dakur opened this issue Jan 25, 2021 · 3 comments
Open

Cannot redeclare block when using condition in {embed} #253

dakur opened this issue Jan 25, 2021 · 3 comments

Comments

@dakur
Copy link
Contributor

dakur commented Jan 25, 2021

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.

@dakur dakur changed the title Cannot redeclare block when using condition in embed Cannot redeclare block when using condition in {embed} Jan 25, 2021
@dg
Copy link
Member

dg commented Jan 25, 2021

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 dg closed this as completed Jan 25, 2021
@dakur
Copy link
Contributor Author

dakur commented Jan 26, 2021

@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?

@dg
Copy link
Member

dg commented Jan 26, 2021

It is conceptually impossible. It is something like

class Foo
{
	if (3 === 4) {
		function someBlock()
		{ return 'a' }
	} else {
		function someBlock()
		{ return 'b' }
	}
}

@dg dg reopened this Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants