|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
me2 Smarty n00b
Joined: 13 Aug 2009 Posts: 3
|
Posted: Thu Aug 13, 2009 8:36 am Post subject: Whitespace in {if} fails |
|
|
I'm porting Smarty 2 templates to be compatible with Smarty 3 (latest rev).
I just got this error:
Code: | Code: 0
Error: Syntax Error in template "/var/...l/index.html" on line 214 " <li><a href="/newsletter/">{$NewsletterSubscription }</a></li>" - Unexpected " }", expected one of: "}" , " "
File: /var/.../sysplugins/internal.templatecompilerbase.php
Line: 264 |
It fails on the space after $NewsletterSubscription. It's nicer not to have spaces at the end of the if-statement, but should it be a Syntax Error? |
|
Back to top |
|
me2 Smarty n00b
Joined: 13 Aug 2009 Posts: 3
|
Posted: Thu Aug 13, 2009 9:44 am Post subject: |
|
|
There more. In Smarty 2 this worked:
Code: | {if ! $smarty.foreach.languages.last} - {/if} |
Smarty 3 throws this:
Code: | Code: 0
Error: Syntax Error in template "/var/.../index.html" on line 317 " {if ! $smarty.foreach.languages.last} - {/if}" - Unexpected " ", expected one of: INTEGER , "+" , "-" , "(" , "[" , "$" , "identifier" , "(!,NOT)" , """ , "'" , "boolean" , "null" , "#"
File: /var/.../sysplugins/internal.templatecompilerbase.php
Line: 264 |
I fixed it by removing the whitespace between the exclamation mark and the variable (which gives prettier code). |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Aug 13, 2009 1:51 pm Post subject: |
|
|
Please note that in Samrty3 you can control with with spaces if the standard delimiters ({ and }) used for a Smarty tag or if they are part of javascript.
{something} is a Smarty tag
{ something } is not interpreted by Smarty, for example in Javascript code
The later allows the use of { and } in Javascript without the need to put {literal} tags around it.
There are some other cases where Smarty 3 currenty does not like withespaces where Smarty 2 did. It is an open task to make the lexer/parser of Smarty 3 more tolerant for whitspaces. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|