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

extends append bug

 
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
tpanula
Smarty Rookie


Joined: 19 May 2003
Posts: 6

PostPosted: Mon Dec 14, 2015 2:47 pm    Post subject: extends append bug Reply with quote

Just found out. Use default smarty 3.1.28, default install as downloaded. Have three template files as follows:

boilerplate.tpl:
{block name="scripts"}{/block}

base.tpl:
{extends file="boilerplate.tpl"}
{block name="scripts" append}
hurahuhhahhei
{/block}

index.tpl:
{extends file="base.tpl"}
{block name="scripts" append}
whatever
{/block}

Result:

Fatal error: Uncaught --> Smarty: inheritance: tag {$smarty.block.parent} used in parent template block 'scripts' <-- thrown in /var/www/smartybug2/smarty-3.1.28/libs/sysplugins/smarty_internal_runtime_inheritance.php on line 156
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Tue Dec 15, 2015 2:46 am    Post subject: Reply with quote

You have uses {block name="scripts" append} in the parent file index.tpl.

Option flags like append are only defined and useful for child templates.
See http://www.smarty.net/docs/en/language.function.block.tpl

Previous Smarty versions did not check for this error.
Back to top
View user's profile Send private message
tpanula
Smarty Rookie


Joined: 19 May 2003
Posts: 6

PostPosted: Tue Dec 15, 2015 8:09 am    Post subject: Reply with quote

So, it's not a bug, but a feature? You have a peculiar sense of usefulness.

I see the append as a mechanism to add content into an existing block, which to me sounds quite useful. Sure, I can take the content from the parent block, put it to the include file and then separately include that content in the parent template, and then again in the subtemplate. But I really thought these blocks were meant to get rid of the include mess and provide some hierarchical way of designing templates.



U.Tews wrote:
You have uses {block name="scripts" append} in the parent file index.tpl.

Option flags like append are only defined and useful for child templates.
See http://www.smarty.net/docs/en/language.function.block.tpl

Previous Smarty versions did not check for this error.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Dec 15, 2015 10:40 pm    Post subject: Reply with quote

tpanula wrote:
I really thought these blocks were meant to get rid of the include mess and provide some hierarchical way of designing templates.

Yes, they do that.
Just not in the way you have thought they do.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Wed Dec 16, 2015 3:15 am    Post subject: Reply with quote

Sorry, I was wrong. I must check it out.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Dec 17, 2015 8:32 pm    Post subject: Reply with quote

Turned out that this was cause by a bug. The fix is now in github in the master branch.
We will release 3.1.29 with bug fixes soon.
Back to top
View user's profile Send private message
jeffreydwalter
Smarty n00b


Joined: 26 Oct 2012
Posts: 2

PostPosted: Sat Dec 19, 2015 8:46 am    Post subject: Reply with quote

U.Tews wrote:
Turned out that this was cause by a bug. The fix is now in github in the master branch.
We will release 3.1.29 with bug fixes soon.


You Smarty devs need to get it together... You guys constantly introduce regression, especially in the template inheritance part of Smarty. *sigh* It's getting old already... Twig is looking better an better!
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Dec 19, 2015 3:38 pm    Post subject: Reply with quote

jeffreydwalter wrote:
U.Tews wrote:
Turned out that this was cause by a bug. The fix is now in github in the master branch.
We will release 3.1.29 with bug fixes soon.


You Smarty devs need to get it together... You guys constantly introduce regression, especially in the template inheritance part of Smarty. *sigh* It's getting old already... Twig is looking better an better!

Someone has to do it. Are you volunteering?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Dec 21, 2015 9:43 pm    Post subject: Reply with quote

jeffreydwalter wrote:
U.Tews wrote:
Turned out that this was cause by a bug. The fix is now in github in the master branch.
We will release 3.1.29 with bug fixes soon.


You Smarty devs need to get it together... You guys constantly introduce regression, especially in the template inheritance part of Smarty. *sigh* It's getting old already... Twig is looking better an better!


When Smarty has a regression bug, a test case is added to minimize further regression. It's easy to avoid regression when your code base doesn't change much, if at all. When regression happens, that is usually a sign of big changes. Smarty is changing and adapting to better suit everyone's needs and take advantage of new things in PHP core. Despite it's vast feature set, Smarty is fast and lean with a small memory footprint. Don't take my word for it, benchmark it against the rest. People seem to think Smarty is old and lethargic just because it has been around awhile. Truth is, it is a very modern and actively developed template engine. Thanks goes to Uwe for all of his hard work.

[edit] this update include run-time template inheritance. Faster, more flexible inheritance system by basically replacing the entire existing inheritance code base to make it work this way. That is a lot of code change, and not an easy task to do and not have anything break. More test cases are being added to further strengthen the stability of this part of the code.
Back to top
View user's profile Send private message Visit poster's website
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