|
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 |
ilyalyu Smarty Regular
Joined: 03 Nov 2009 Posts: 72
|
Posted: Fri Jul 27, 2012 9:59 pm Post subject: functions in parent template (template inheritance) |
|
|
I have around 20 function definitions in parent template. These function definitions are included in each child template, which I think increases compiled templates size and decreases performance.
I tried to move these function definitions to a separate template and include it with {include}. However, in this case I get an error message that says that the function is not defined. I know that I can use {call 'fn'} instead of {fn}, but it is inconvenient.
So, the question: is it possible to move function definitions to a separate template in an efficient way?
For example, there could be {library 'my-functions.tpl'} syntax, where:
1. my-functions.tpl may contain only functions
2. my-functions.tpl is included only once even if there are multiple occurences of {library 'my-functions.tpl'}.
3. functions from my-functions.tpl can be called with short notation (i.e. {fn} instead of {call 'fn'}). |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Jul 28, 2012 8:55 am Post subject: |
|
|
The reason why you have to use {call 'fn'} for external defined functions is that the compiler does not see these functions during compilation and the function library may not be loaded at that time. The compiler has to generate different compiled code for the two cases. |
|
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
|