View previous topic :: View next topic |
Author |
Message |
Aryos Smarty Rookie
Joined: 12 Jan 2010 Posts: 8
|
Posted: Tue Jan 12, 2010 11:21 am Post subject: Handling of {if tags in Smarty 3 |
|
|
Just a small nuisance (not a bug), but would be convenient to fix it.
In Smarty 2, syntax of {if tags like:
works
In Smarty 3, this raises an exception
Notice the extra space character between "{" and "if". Normally, it would not be good for this to work, because this is not the appropriate syntax, however it would be handy for backwards compatibility with Smarty 2, because I'm sure quite a few people, here and there, may have this syntax "error" in old, Smarty 2 templates. |
|
Back to top |
|
grmbl Smarty Rookie
Joined: 12 Jan 2010 Posts: 7
|
Posted: Tue Jan 12, 2010 11:56 am Post subject: |
|
|
I think it takes like 15 minutes to fix wrong templates with mass search and replace.
PHP was aimed to be backwards-compatible with crappy coding practices - look at the mess it is now. |
|
Back to top |
|
Aryos Smarty Rookie
Joined: 12 Jan 2010 Posts: 8
|
Posted: Tue Jan 12, 2010 12:44 pm Post subject: |
|
|
More like half a minute
This is not a request for me, I just thought there would be some people not knowing what's wrong when they see this exception message, thus not able to fix it right away. |
|
Back to top |
|
ChrisFah Smarty Pro
Joined: 02 Nov 2009 Posts: 159 Location: Traun, Austria
|
Posted: Tue Jan 12, 2010 12:45 pm Post subject: |
|
|
I also think:
Better change template than code becuse of this tiny fact.
Regards, Chris |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Jan 12, 2010 3:26 pm Post subject: |
|
|
Smarty 3 raises an exception because { and } tags with whitespace are ignored so you don't have to escape javacript/css. So when you do this:
{ if foo}
Smarty see it as
if foo}
(no opening tag) and throws the exception. This is a small nuance of Smarty 3, but rids the need for {literal} tags all over the place. You can also revert the behavior with $smarty->auto_literal = false. |
|
Back to top |
|
Aryos Smarty Rookie
Joined: 12 Jan 2010 Posts: 8
|
Posted: Tue Jan 12, 2010 5:49 pm Post subject: |
|
|
Thanks for the feedback, this makes sense.
One thing I'd like to ask is if the "auto-literal" function makes execution times any faster or if it's added just for convenience in coding templates. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Jan 12, 2010 7:22 pm Post subject: |
|
|
I doubt there is any significant difference in performance, its just a change in how templates are compiled. |
|
Back to top |
|
Michael White Smarty Rookie
Joined: 08 Oct 2009 Posts: 20
|
Posted: Thu Jan 14, 2010 5:46 am Post subject: |
|
|
This error is present in many of our templates. However, I think that being able to drop {literal} is such a bonus that we'll just fix the templates. |
|
Back to top |
|
|