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

Latte 2.9 broke {last}...{else}...{/last} #247

Closed
matronator opened this issue Dec 19, 2020 · 2 comments
Closed

Latte 2.9 broke {last}...{else}...{/last} #247

matronator opened this issue Dec 19, 2020 · 2 comments

Comments

@matronator
Copy link

matronator commented Dec 19, 2020

Version: 2.9.2

Bug Description

I'm updating dependencies on an older(-ish) project and noticed some unannounced breaking changes. In the previous version the project used (2.6.2), it was possible to use the {else} tag with the {last} tags in a {foreach} in the same way you would use {if}...{else}...{/if} and I used it as a shorthand for {if $counter->isLast()}...{else}...{/if}.

This is no longer possible, probably due to the addition of {else} with {foreach} and throws Tag {else} is unexpected here in ... and there is no (I can't find any) mention of it anywhere.

Steps To Reproduce

For example you could write something like this:

{foreach $items as $item}
  {last}
    I'm the last {$item} :(
  {else}
    I'm NOT the last {$item} :P
  {/last}
{/foreach}

Expected Behavior

Compile and work as before (if $last ?: else).

Possible Solution

Due to the fact that I couldn't find any mention of this change (or for that matter the behavior itself), I'm starting to think that this behavior was actually a bug, not a feature and was undiscovered? Maybe because the {last} tag was compiled to a regular if statement, it didn't throw any error, because else is completely valid after an if/else if?

{if} that's the case, then I guess you can change the issue from a Bug report to a Feature request to bring this feature back, even though it was never officially a feature, because it was a bug, but wasn't know about and fix the new bug that is actually not a bug, but a feature, but accidentally fixed (or broke) the previous real bug and turn that bug into a real feature, without breaking any existing features or accidentally fixing more bugs. *gasps for air* I don't know, I'm confused as well...

@dg dg closed this as completed in c9d37a3 Dec 20, 2020
@dg
Copy link
Member

dg commented Dec 20, 2020

Yes, it was not a feature, but it is not a problem to add it.

@matronator
Copy link
Author

Awesome, thank you!

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