|
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 |
dreamwing Smarty Rookie
Joined: 17 Dec 2009 Posts: 5
|
Posted: Wed Apr 13, 2011 9:51 am Post subject: static class can not be used in {extends file=""}? |
|
|
{extends file="{myClass::method()}/header.tpl"} will trigger an error:
"illegal value for file attribute"
but if I use $tpl_dir = myClass::method(); and then use $dir in template
{extends file="{$tpl_dir}/header.tpl"} this is ok.
My point is now that in Smarty3 we can access static class directly in template, why not add this feature to extends syntax?
And thx for the fantastic {extends} syntax~ |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Apr 13, 2011 3:41 pm Post subject: |
|
|
As the template inheritance is processed at compile time the {extends} tag should accept only constant strings. It's a bug that it did accept the $tpl_dir variable. A change of it's value would not be detected.
If you need variable templates use the exteds resource at script level like
$smarty->display('extends:layout.tpl|myproject.tpl|mypage.tpl');
Here you can safely use a variable string. |
|
Back to top |
|
dreamwing Smarty Rookie
Joined: 17 Dec 2009 Posts: 5
|
Posted: Sun Apr 24, 2011 6:26 am Post subject: |
|
|
thx for the script level resolution, althought I think it would be more convenient to use variables in {extends} tag |
|
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
|