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

The {else} tag should not accept arguments silently #1089

Open
saulery opened this issue Nov 29, 2024 · 0 comments
Open

The {else} tag should not accept arguments silently #1089

saulery opened this issue Nov 29, 2024 · 0 comments

Comments

@saulery
Copy link

saulery commented Nov 29, 2024

Hello,

I have a specific Warranty field that tells me the warranty period that applies beyond the legal warranty. Its value can be 0 to N, 0 for no warranty extension beyond the legal warranty. So I want to display the corresponding mention only when the specific warranty is greater than zero. In addition, I have to manage the plural on the year.

The code should have been this:

{if $specific_warranty_in_year > 1}
   <p>Specific guarantee : {$specific_warranty_in_year} years</p>
{elseif $specific_warranty_in_year eq 1}
   <p>Specific guarantee : {$specific_warranty_in_year} year</p>
{/if}

I made a mistake and typed 'else' instead of 'elseif'.

{if $specific_warranty_in_year > 1}
   <p>Specific guarantee : {$specific_warranty_in_year} years</p>
{else $specific_warranty_in_year eq 1}
   <p>Specific guarantee : {$specific_warranty_in_year} year</p>
{/if}

Which to my surprise displays "Specific guarantee : 0 year" instead of causing an error.

I guess the parser doesn't know how to distinguish between 'else' and 'elseif', and doesn't know that 'else' doesn't accept arguments.

Regards,

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

1 participant