For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > April 2004 > flexy global functions









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author flexy global functions
Demian Turner

2004-04-24, 12:31 pm

Hi Alan/all

just testing out your new global functions (0.8.1), i've used the syntax
indicated in the changelog:

{GLOBALS.date(mydate,#d/m/y#)}

and put it in a conditional

{if:GLOBALS.is_array(v)}
... do something
{end:}

however this does not seem to work. the 'globalfunctions' = true is set.

an a related note, it is possible to create custom functions for flexy?
i know this was implemented for the old regex parser, don't think it
works the current one. currently we're using the output object to add
methods which can be called by flexy templates, however the issue is
that say we have 50 html transform methods, we call all of them every
page execution even if the current page uses only one of them.

the advantage of having them in flexy (i believe) is that if the pages
are compiled, the addition html methods won't get included/called,
making the process considerably more streamlined.

cheers

demian
Alan Knowles

2004-04-27, 5:09 am

Demian Turner wrote:
> Hi Alan/all
>
> just testing out your new global functions (0.8.1), i've used the syntax
> indicated in the changelog:
>
> {GLOBALS.date(mydate,#d/m/y#)}
>
> and put it in a conditional
>
> {if:GLOBALS.is_array(v)}
> ... do something
> {end:}
>
> however this does not seem to work. the 'globalfunctions' = true is set.


can you file it as a bug - I need to fix it..
>
> an a related note, it is possible to create custom functions for flexy?
> i know this was implemented for the old regex parser, don't think it
> works the current one. currently we're using the output object to add
> methods which can be called by flexy templates, however the issue is
> that say we have 50 html transform methods, we call all of them every
> page execution even if the current page uses only one of them.
>
> the advantage of having them in flexy (i believe) is that if the pages
> are compiled, the addition html methods won't get included/called,
> making the process considerably more streamlined.


have you got a simple example, so I can get my head round the requirements..

Technically, the Tag Namespace handler is supposed to deal with this,
although It's more a proof of concept..

eg. at present
<flexy:toJavascript is in HTML/Template/Flexy/Compiler/Standard/Flexy.php

if you start using:
<seagull:dosomething ....
it should call
HTML/Template/Flexy/Compiler/Standard/Seagull.php

or
<XUL:textarea ....
calls HTML/Template/Flexy/Compiler/Standard/XUL.php


at present, the file path is hard coded.. it may be worth adding yet
another option:

'namespaceHandlers' => array(
'XUL' => '/myproject/XUL.php' /// maps to class : myproject_XUL
)

Regards
Alan


Regards
Alan

>
> cheers
>
> demian



--
Can you help out?
Need Consulting Services or Know of a Job?
http://www.akbkhome.com
Demian Turner

2004-04-29, 6:48 pm

hi Alan

apologies for the slow reply:

>
>
> can you file it as a bug - I need to fix it..


filed

>
>
> have you got a simple example, so I can get my head round the
> requirements..
>
> Technically, the Tag Namespace handler is supposed to deal with this,
> although It's more a proof of concept..
>
> eg. at present
> <flexy:toJavascript is in HTML/Template/Flexy/Compiler/Standard/Flexy.php
>
> if you start using:
> <seagull:dosomething ....
> it should call
> HTML/Template/Flexy/Compiler/Standard/Seagull.php
>
> or
> <XUL:textarea ....
> calls HTML/Template/Flexy/Compiler/Standard/XUL.php
>
>


sounds very much like what I'm trying to explain - the ability to make a number
of methods available to a namespace, as you say <seagull:method1(arg1,arg2)>
<seagull:method2(arg3,arg4) ...

following the current tag attribute convention, i'm not sure if the mapping is
ideal for method calls, for example,

<seagull:generateSelect options="aKeyValueList" selected="myKey">

how methods are currently made available is a much more intuitive one-to-one
mapping, ie & #123;generateSelect(aKeyValueList,myKey)
}

the attractiveness of such a feature is that, for example in our framework, say
we have 50 html transform methods, we have 2 options

- load a huge static method lib file with every page exec, very inefficient when
only 1-2 methods are called
- load a separate lib for each module, messy

If such template methods could be incorporated into Flexy, then once compiled,
this potentially huge class would never get called :-)

> at present, the file path is hard coded.. it may be worth adding yet
> another option:
>
> 'namespaceHandlers' => array(
> 'XUL' => '/myproject/XUL.php' /// maps to class : myproject_XUL
> )


agreed that including the 3rd party lib outside of the pear class library would
be a good idea.

what do you think?

cheers

demian
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com