IT[X]: variable scope in template engines?
| From: | Dietrich Ayala | Date: | Tue, 12 Mar 2002 19:31:19 +0000 |
| Subject: | IT[X]: variable scope in template engines? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-954@lists.php.net to get a copy of this message | ||
I have a problem with the fact that in IT[X], variable placeholders aren't contained within
blocks, and have a global scope by
default (AFAIK). Does anyone else have problems with this?
So I use a custom version of IT[X] in which I implemented block-level variable scoping, ie: variable
names are contained within the
block they are originally registered in. This allows me to have the placeholder 'title' in
my global template, and a placeholder by
the same name in my 'news_items' block, without fear of collision. I also implemented a
'global variable' notation, so as to allow
access to variables from other blocks.
My question: How do some of the other PHP template engines treat variable scope? They must use the
'block' concept or something
similar. Do they allow child blocks to 'inherit' variables from higher up in the
hierarchy?
I have briefly tried Smarty and Fast Template, but not deeply enough to figure this stuff out. I
really liked the IT[X] API, so I
stuck with it. I also *like* that the IT[X]'s feature set is really small: no programming
inside the templates, other than looping.
This forces my logic and content to be separate. (I find that I must assume that graphic designers
do not understand basic
programming concepts that we take for granted, because most aren't able to make heads or tails
of a Smarty template that takes
advantage of all the programming that is allowed *inside* the template. But that's a rant for
another time ;)
> -----Original Message-----
> From: Dietrich Ayala [mailto:dietrich@ganx4.com]
> Sent: Tuesday, March 12, 2002 11:11 AM
> To: Stig S. Bakken; marcbey
> Cc: pear-general@lists.php.net
> Subject: RE: [PEAR] IT[X] change output device?
>
>
> Also, the get() method returns the parsed contents of the current template as a string (all the
> show() method does is
> call get() and
> print it's return value).
>
> If no block names are passed to get(), it'll parse from the global template, ie: parse
> everything.
>
> > -----Original Message-----
> > From: Stig S. Bakken [mailto:ssb@fast.no]
> > Sent: Tuesday, March 12, 2002 7:54 AM
> > To: marcbey
> > Cc: pear-general@lists.php.net
> > Subject: Re: [PEAR] IT[X] change output device?
> >
> >
> > On Mon, 2002-03-11 at 17:53, marcbey wrote:
> > > is it possible to load an template such a template.txt,
> > > parse it, but dont send to to the browsers output, because the template is
> > > text for an email?
> > >
> > > who can i do this with IT template ?
> >
> > Just do ob_start(), let your template output what it should, catch the
> > output with ob_get_contents() and finish with ob_end_clean().
> >
> > - Stig
> >
> >
> > --
> > PEAR General Mailing List (http://pear.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>