Menu

#31 Require of plugins is not template-dependent

Current_Version
closed
5
2017-11-17
2007-07-28
BohwaZ
No

Example:

main.tpl
{include file="head.tpl"}

{$title|escape}

head.tpl
<title>{$title|escape}</title>

other.tpl
{include file="head.tpl"}

Test

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

Discussion

  • Mark Dickenson

    Mark Dickenson - 2007-07-31

    Logged In: YES
    user_id=752816
    Originator: NO

    I added your fix to the next release. Thanks :)

     
  • BohwaZ

    BohwaZ - 2008-02-08

    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.

     
  • jon

    jon - 2008-03-01

    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

     
  • Don Duvall

    Don Duvall - 2017-11-17

    It looks like the previous montainer had implemented this, without closing the ticket. Thanks for the contribution.

     
  • Don Duvall

    Don Duvall - 2017-11-17
    • status: open --> closed
     

Anonymous
Anonymous

Add attachments
Cancel