Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Smarty 3 should be more php compliant

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
dleffler
Smarty Rookie


Joined: 20 Sep 2011
Posts: 8

PostPosted: Thu May 10, 2012 3:35 pm    Post subject: Smarty 3 should be more php compliant Reply with quote

In php 'notice' warnings are displayed for things like referencing an uninitialized array/object, etc... In turn, the smarty compiler outputs some unclean code. e.g.,
Code:
{if $permissions.create == 1 && empty($hidebox)}
outputs
Code:
<?php if ($_smarty_tpl->tpl_vars['permissions']->value['create']==1&&$_smarty_tpl->tpl_vars['hidebox']->value==0){?>
which generates these warnings
Code:
Notice: Undefined offset: -1 in C:\UwAmp\www\exp2\tmp\views_c\f6e525a8e0cb94aa52198089c47123dd^685127c111bb65f53550deca737d502e65d76e5a.file.YUI Top Nav.tpl.php on line 61
Code:
Notice: Trying to get property of non-object in C:\UwAmp\www\exp2\tmp\views_c\f6e525a8e0cb94aa52198089c47123dd^685127c111bb65f53550deca737d502e65d76e5a.file.YUI Top Nav.tpl.php on line 61
'empty' should be compiled to the empty php function, right?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu May 10, 2012 7:32 pm    Post subject: Reply with quote

It does correctly compile to

<?php if ($_smarty_tpl->tpl_vars['permissions']->value['create']==1&&empty($_smarty_tpl->tpl_vars['hidebox']->value)){?>

Which version of Smarty did you use?
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP