Re: Play nice! Re: Savant/Flexy/Foo template engines

From: Date: Thu, 10 Jun 2004 13:35:55 +0000
Subject: Re: Play nice! Re: Savant/Flexy/Foo template engines
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-30385@lists.php.net to get a copy of this message
Alan Knowles wrote:
c) What is missing
- Does the tokenizer detect strings at Javascript code?
the tokenizer ignores Javascript completely.. if you are using the tokenizer backend, you should use something like <flexy:toJavascript javascript_var="php_var"> <script type="text/javascript"> javascript_var = 'a default'; </script> </flexy:toJavascript> This enables you to test the template and the javascript without compiling it..
What I did long time ago for an i18n proyect was to make the _() function avaible in HTML. So you just do: <input type="submit" value="_('Ok')"> This worked the same under JS or whatever is inside the template. The template engine takes care on do the right replacements. A "don't use example": preg_replace('/(_\(([^(])*\))/e', 'gettext(\1)', $tpl_string); The isolation of the string needed a script btw, was not magically done as yours.
- I saw the nice number format option, could it be set to locale? Why not do something similar with dates?
Thats a kludge, I suspect the best way to handle this is really to use {plugin(#mynumberformat#,thevar)} -- or make the plugins callable as modifiers.. : eg. {var:mynumberformat} does the same as the above..
I love the idea of calling plugins as modifiers.
- About the rewriting engine, a think like images/:images/{$flexy_locale}/, would help full i18n
Another very kludgy implimentation :) - I think the engine should really replace the <img src="images/someimage.gif" with <img src="<? echo $this->plugin('ImageSource::fix', 'images/someimage.gif') ?>" .... and 'compiler.standard.image_rewriter' => array('myclass','imagefixer') or something...
IMHO half-way features shouldn't get included until they gets more flexibility and usability. Otherwise it could become be a "flame me" point ;)
- Please keep the usage as simple and easy as possible, is the only way to get success.
yeah - the dumbest usage Savant Mode: $x = new Template(array('template_dir'=>dirname(__FILE__)); $x->open('mytemplate.php'); $x->outputWithData(array( 'variables' => array(
      'somevar1' => 'xxxx'
))); dumbest usage Flexy/Tokenizer Mode: $ x = new Template(array(
        'template_dir'=>dirname(__FILE__)
        'complier'=>'Standard',
); $x->open('mytemplate.html'); $x->outputWithData(array( 'object' => $this)); with Assign API: $x = new Template(array('template_dir'=>dirname(__FILE__)); $x->open('mytemplate.php'); $x->setData('somevar1','xxxx'); $x->output();
Nice yeah. Just the outputWithData() func name hurts my eyes a little :-) Tomas V.V.Cox

« previous php.pear.dev (#30385) next »