[prev in list] [next in list] [prev in thread] [next in thread] 

List:       smarty-dev
Subject:    Re: [SMARTY-DEV] What happened to _compile_string()?
From:       messju mohr <messju () lammfellpuschen ! de>
Date:       2003-11-28 14:34:00
[Download RAW message or body]

On Fri, Nov 28, 2003 at 01:32:07PM +0000, Marcus Bointon wrote:
> Something that I do a lot of is create smarty interpreted strings on the
> fly, e.g. for the subject of an email, rather than anything coming from a
> file. To date I've been using a superclass of Smarty that adds a function to
> compile a template from a string. It broke when I upgraded to 2.6.
> Internally it calls _compile_string(), which seems to not exist any more
> (serves me right for using a private function ??!), so I needed to know what
> the equivalent is now. I took a guess at _compile_source and that does seem
> to work. My function is now:
> 
[...]
>
> I thought that since many others may be doing something similar, this would
> be useful for the list.
> 
> Is it time to request this again as a standard Smarty feature? Or have I
> missed something else in 2.6?

first of all, i'd say its very ugly to let smarty operate on strings
instead of files or other resources. you end up compiling the template
every time you display it. you give away smarty's main strength: the
ability to compile a template once but use it many times after that.

if you don't bother and think you really need to do that, a portable
(over different versions of smarty) solution would be:

require_once $smarty->_get_plugin_filepath('function', 'eval');
smarty_function_eval(array('var'=>$your_template_here), $smarty);

greetings
messju

 
> Marcus

-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic