Re: your mail

From: Date: Tue, 29 Feb 2000 03:32:05 +0000
Subject: Re: your mail
References: 1  Groups: php.template 
Request: Send a blank email to php-template+get-237@lists.php.net to get a copy of this message
> Some of these may be simply an outgrowth of my very limited exposure to > PHP so please feel to correct any invalid assumptions I've made. Will do. > 1. I think it's better to make template files look just like normal > PHP files as far as grammar goes. In other words, don't introduce a > special/custom series of tags/delimiters that are only unique to a PHP > template that look out of place. eg {{<var>}} or {{* ... *}} but instead > try: > > <?php $variable [<attributes>] ?> > > Now the question here is how does the parser know that it's supposed > to do the equivalent of "print $variable" or not depending on if > '$variable' happens to > be in an enclosing body of code? I think it's a parser issue which > should't be too hard to figure out: ie. if it's inside a code body, don't > treat it like a template item. Or maybe "$$variable" is the special > template case or something like that (ala shells). > > If the variable is a straightforward array it's pretty easy to iterate > thru it. But what if it's an associative array? or a multi-dimentional > one? What then? Believe me, I've already been through the "what if we just use PHP commands" phase, and more than once, while designing this beast. And I've asked the same questions as you and the just don't have good answers. Some of the basic problems are: incomprehesibility for designer, pollution of PHP namespace with our arrays, implementing sections as PHP constructs, getting the template output as a string instead of just having it printed out (well this can be done using buffering, but still). > The way the Python module did it was thus: > > #template spec# > > :pageTag [ > <HTML><BODY> > <TABLE> > :paragraph1 > <TR BGCOLOR=%s><TD>%s</TD> > :paragraph2 > :paragraph3 > ] > > :pageTag2 [ > :paragraph1 > ] > > And then the Template() functions would be called such that: > startTemplate(Page1); /* which would print up to ":paragraph1" and > stop */ > printTemplate(paragraph1, "green", "books); > ... Ouch, %s? Come on, we're talking about designers here. They need to see how the things are named. > Did that awkward, jumbled mess of thoughts make any sense? what do you all > think? I've looked at other templating solutions, and I don't like any of them. :) The closest one that I found was HTML::Template for Perl and I borrowed some ideas from that. I wonder if you can tell us why you don't like the proposed template language and for what reasons. -Andrei

« previous php.template (#237) next »