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

ForEach unrecognized Syntax Error on double brackets {{}} #530

Open
DoktorD opened this issue Jan 15, 2019 · 2 comments
Open

ForEach unrecognized Syntax Error on double brackets {{}} #530

DoktorD opened this issue Jan 15, 2019 · 2 comments

Comments

@DoktorD
Copy link

DoktorD commented Jan 15, 2019

I have "{" and "}" characters set as my delimiters. I made a syntax error and closed my foreach loop with double brackets.
{ foreach $var as $vars }     {* code here *}  {{ /foreach }}  // <---- SYNTAX ERROR

Not only did Smarty not warn me of the error but it parsed the code and executed. Needless to say this was hard to diagnose because the error spilled out into multiple templates and even my normal php scripts and that was due to the foreach loop using an output buffer layer for each iteration that when unproperly closed and not handled by smarty as error get carried over to general scripts.

@AnrDaemon
Copy link
Contributor

I see it is working like nothing happened https://github.com/AnrDaemon/test-001/tree/issue-530

But I question the behavior.

@wisskid
Copy link
Contributor

wisskid commented Mar 21, 2021

The double brackets cause nested behavior. Smarty probably parses the inner {/foreach} first and then tries to output the "result" of that statement. And there indeed seems to be a relation to #552 here. It's not specifically related to foreach. The following has similar compilation results:

{foreach [1, 2, 3] as $var}
	T1 {$var}
{{/foreach}}

{foreach [4,5,6] as $var}
	T2 {$var}
{/foreach}

{if true}
	T3 {$var}
{{/if}}

{if true}
	T4 {$var}
{/if}

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

3 participants