Re: runtime template parsing

From: Date: Mon, 07 May 2001 13:16:48 +0000
Subject: Re: runtime template parsing
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-688@lists.php.net to get a copy of this message
write a custom function that writes the variable out to a file, then include it. // php code, untested function smarty_write_file () { extract(func_get_arg(0)); if(isset($file) && isset($contents)) { $this->_write_file($file,$contents); } } $smarty->register_function("write_file","smarty_write_file"); {* in your template *} {write_file file="/tmp/body.tpl" contents=$body} {include file="/tmp/body.tpl"} Ivo Jansch wrote: > > Hi, > > In my templated site, I have some content, which contains embedded > template syntax. > > It's easier to explain what I mean by giving an example: > > main.tpl: > > <html> > <body> > {$title} > <hr> > {$body} > > ---<BR> > You are currently subscribed to smarty as: monte@ispi.net<BR> > To unsubscribe send a blank email to $subst('Email.Unsub')<BR> > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/ > </BODY> > </html> > > $title and $body are assigned in main.php, where they are read from a > database first. > > Now suppose $body contains stuff like {include} or a repetition of > {$title} or some other template syntax. > > Is there an easy way to call the template parser at runtime? Smarty > would have to compile to a temporary file, I guess, and include that. > > Greetings, > Ivo > > -- > Ivo Jansch <ivo@ibuildings.nl> > ibuildings.nl BV - information technology > http://www.ibuildings.nl -- Monte Ohrt <monte@ispi.net> http://www.ispi.net/

« previous php.smarty.general (#688) next »