Re: recommendations for an EASY TO LEARN & USE template system?
| From: | l Burnerheimerton | Date: | Wed, 12 Jan 2005 22:38:03 +0000 |
| Subject: | Re: recommendations for an EASY TO LEARN & USE template system? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16905@lists.php.net to get a copy of this message | ||
How would you set up you file to include - how would
it know where to put the values?
Thanks
--- Paul M Jones <pmjones@php.net> wrote:
> Lukas Smith wrote:
> > Paul M Jones wrote:
> >
> >> Lukas Smith wrote:
> >>
> >>>> Any recommedndations?
> >>>
> >>>
> >>>
> >>>
> >>> PHP!
> >>>
> >>> extract($__data__);
> >>> unset($__data__);
> >>> ob_start();
> >>> include $__file__;
> >>> $content = ob_get_contents();
> >>> ob_end_clean();
> >>
> >>
> >>
> >> Hear hear! But don't forget to "echo $content;"
> at the end there or
> >> you'll wonder why all the pages are blank. ;-)
> >
> >
> > Actually echo'ing is not the job of a template
> engine.
>
> Looking at this, you can actually get it a bit
> shorter, and not have to
> worry about variable name conflict, although it
> might not throw errors
> the way you expect it should. Requires PHP >=
> 4.3.0.
>
> <?php
> // func_get_arg(0) is the file to include
> // func get_arg(1) is the data array
> function getRenderedTemplate()
> {
> extract((array) func_get_arg(1));
> ob_start();
> include func_get_arg(0);
> return ob_get_clean();
> }
> ?>
>
> Of course, you still need to echo it at the end or
> you won't see anything.
>
>
> -- pmj
>
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com