Example:
main.tpl
{include file="head.tpl"}
head.tpl
<title>{$title|escape}</title>
other.tpl
{include file="head.tpl"}
While compiling, template_lite will put plugins requires at the beginning of the compiled file for main.tpl, but not for head.tpl. And while loading other.tpl it will produce an error as the modifier is not loaded.
I worked on a patch[1] but it's a bit dirty I think. You'll have to make the plugins requirements template-dependent.
[1] http://svn.kd2.org/wsvn/misc/libs/template_lite/class.template.php?op=diff&rev=433&sc=1 and http://svn.kd2.org/wsvn/misc/libs/template_lite/internal/template.fetch_compile_include.php?op=diff&rev=0&sc=1
Anonymous
Logged In: YES
user_id=752816
Originator: NO
I added your fix to the next release. Thanks :)
Logged In: NO
I discovered a bug in template_lite after my change, please see http://svn.kd2.org/wsvn/misc/libs/template_lite/class.template.php?op=diff&rev=0&sc=1
Logged In: YES
user_id=1381409
Originator: YES
This wasn't a very good idea, it broke some cases like :
$tpl->register_modifier('doSthg', 'tpl_do_something');
file index.tpl:
{include file="head.tpl"}
file head.tpl:
{$title|doSthg}
-> modifier doSthg not found
That's because my patch cleared _plugins for included templates. Now I found a better (temporary) solution, you could find it here :
http://svn.kd2.org/wsvn/misc/?op=comp&compare%5B%5D=%2Flibs%2Ftemplate_lite@550&compare%5B%5D=%2Flibs%2Ftemplate_lite@551
But the best solution is to rewrite the plugin management to get something a bit cleaner.
Logged In: YES
user_id=695210
Originator: NO
To fix:
class.compiler.php:
move if statement for:
// check for a plugin in the plugin directory
ABOVE if statement for:
// check for standard functions
So, that ensures that every time there is a non-standard function, it's require line is specified. Otherwise, once it's been required the first time, the "function exists", so it's assumed to be a native function that needs no require.
Cheers
Note: fix is attached here - http://sourceforge.net/tracker/index.php?func=detail&aid=1905129&group_id=163694&atid=828751
It looks like the previous montainer had implemented this, without closing the ticket. Thanks for the contribution.