NYCPHP Meetup

NYPHP.org

[nycphp-talk] Looking for a PHP equivalent to Perl Text::Templ ate

Malcolm, Gary gmalcolm at professionalcredit.com
Tue May 6 12:17:52 EDT 2003


does this strike anyone as a little dangerous? hiding executable code that
operates at the same level of permissions amongst text files could get
confusing in large batches... especially if the replacement gets complex.

maybe build a simple template function  lib based on str_replace... that way
all your logic can stay in one file and allow someone else to upkeep the
documents.

> -----Original Message-----
> From: Carlos A Hoyos [mailto:cahoyos at us.ibm.com]
> Sent: Tuesday, 06 May, 2003 9:07 AM
> To: NYPHP Talk
> Subject: Re: [nycphp-talk] Looking for a PHP equivalent to Perl
> Text::Template
> 
> 
> 
> 
> 
> 
> 
> 
> 
> You can use the output buffer functions. Easier than eval, 
> and you can use
> all of the php functions to build the output.
> Look at ob_start() and ob_get_contents()....
> 
> this are one of the overlooked treassures in php ; )
> 
> Carlos
> 
> 
>                                                               
>                                                               
>           
>                       Chris Snyder                            
>                                                               
>           
>                       <chris at psydeshow.        To:       
> NYPHP Talk <talk at nyphp.org>                                   
>                
>                       org>                     cc:            
>                                                               
>           
>                                                Subject:  Re: 
> [nycphp-talk] Looking for a PHP equivalent to Perl 
> Text::Template         
>                       05/05/2003 06:40                        
>                                                               
>           
>                       PM                                      
>                                                               
>           
>                       Please respond to                       
>                                                               
>           
>                       talk                                    
>                                                               
>           
>                                                               
>                                                               
>           
> 
> 
> 
> Emmanuel. M. Decarie wrote:
> 
> >Hello,
> >
> >I'm looking to a PHP equivalent to the Perl module Text::Template.
> >
> >I was perusing the Smarty documentation, but, maybe I missed
> >something, but it doesn't look that I can use  it the in same way.
> >
> >What I want to do is to assign the result of parsing the template to
> >a variable. This is very convenient for example when you need to send
> >email.
> >
> >---------------------------------------------
> >Perl example:
> >---------------------------------------------
> >
> >Dear {$title} {$lastname},
> >It has come to our attention that you are delinquent in your
> >         {$monthname[$last_paid_month]} payment.  Please remit
> >         ${sprintf("%.2f", $amount)} immediately, or your 
> patellae may
> >         be needlessly endangered.
> >Love,
> >Mark "Vizopteryx" Dominus
> >
> >
> >
> You could do essentially this by bringing the template into your
> controlling script and eval()'ing it -- something like:
> 
> $template= file_get_contents("/path/to/template.html");
> $command= "\\$output= \\"$template\\";";
> eval($command);
> print $output;
> 
> 
> You couldn't pull off the sprintf() call in the middle of that, but
> everything else will work. You don't even need the curly brackets.
> 
>     chris.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --- Unsubscribe at http://nyphp.org/list/ ---
> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20030506/c6ba332e/attachment.html>


More information about the talk mailing list