Page 1 of 1

PHPTal

Posted: Tue Oct 25, 2005 6:45 pm
by Ambush Commander
Once upon a late autumn dreary, while I wandered, weak and weary, oer' the Wikipedia... I descended upon a quaint little templating system... PHPTAL.

At first I was intrigued: now I'm enthused. It's paradigm is absolutely brilliant.

Code: Select all

<div id="item" tal:repeat="value values">
  <div id="item">
    <span tal:condition="value/hasDate" tal:replace="value/getDate"/>
    <a tal:attributes="href value/getUrl" tal:content="value/getTitle"/>
  </div>
  <div id="content" tal:content="value/getContent"/>
</div>
Using XHTML attributes to handle templating was certainly novel and it made a lot of sense. Fowler complains a bit in his section about Template View that often template systems just don't do a good job of seperating business logic from presentation logic. PHPTAL makes the distinction clear, or at least, clearer than other systems as Smarty.

Yet I'm not ready to migrate yet, as after all, you don't fix what isn't broken. Has anyone else had experiences with this templating system? What did you think of it? If you haven't seen this before, does it look interesting?

Posted: Wed Oct 26, 2005 8:36 am
by Maugrim_The_Reaper
It's certainly interesting. I'm just not convinced that meddling with the attributes is the way to go. How is anyone going to explain it to a template designer without a shred of PHP beyond the basics? It looks pretty lean for something like "generic" templates with dynamic data where the layout rarely changes. But I doubt it's suitable in all cases - re: where page layout is more often changeable, and content more likely to be directly added.

Of course everyone has their pet templating methods... If it works for you, it works. My brief outlook is probably pessimistic - its not like I've used it and seen the light ;). It just doesn't seem to meet my own peculiar needs at face value like Savant currently does.

If you are looking at template systems: Savant 2

Posted: Thu Oct 27, 2005 8:02 pm
by Ambush Commander
I'm just not convinced that meddling with the attributes is the way to go. How is anyone going to explain it to a template designer without a shred of PHP beyond the basics?
Well, I would think it's more intuitive to template designers.

Oh, you just concentrate on designing the page. Yeah, you can put in sample text. Just put these tal:content attributes on those containing blocks so that when we actually use your template so that it renders correctly. But yeah, you don't need to run the program to test the template.
Of course everyone has their pet templating methods... If it works for you, it works. My brief outlook is probably pessimistic - its not like I've used it and seen the light Wink. It just doesn't seem to meet my own peculiar needs at face value like Savant currently does.
An interesting perspective. Any other comments?

Posted: Fri Oct 28, 2005 3:59 am
by timvw
Ambush Commander wrote: Well, I would think it's more intuitive to template designers.

Oh, you just concentrate on designing the page. Yeah, you can put in sample text. Just put these tal:content attributes on those containing blocks so that when we actually use your template so that it renders correctly. But yeah, you don't need to run the program to test the template.
In that case you're beter of with xslt because that is a template/transformation language that is available on virtually every platform instead of a php-only one. That way, your designers only have to learn one system... once...

But, php itself has proven to be a very easy to learn template system, so i'm in constant doubt between using php and xml/xslt for a template system.

Posted: Fri Oct 28, 2005 6:44 am
by n00b Saibot
now thats food for thought. i was thinking about that just ½ hr. ago. PHP vs. XML/XSLT... which one to use? can we take a poll or will someone help to make the decision clearer :)

Posted: Fri Oct 28, 2005 8:32 am
by Roja
n00b Saibot wrote:now thats food for thought. i was thinking about that just ½ hr. ago. PHP vs. XML/XSLT... which one to use? can we take a poll or will someone help to make the decision clearer :)
I think its a very easy question: Do you want to display a variable on the screen, at all?

If so, then you will (in some form or another) need to use php. Whether to drive a templating system (Smarty, Savant), to replace placeholders, or otherwise, you'll be using some form of php.

XML and XSLT are great for the final step of display, after you've dealt with processing, and variables, and all of that.

Now, if the question was rephrased slightly to "Should I use a particular templating system or XML+XSLT", thats a rather different question. I think, as Maugrim implies, that each project and developer will have their own preferences.

I personally find a tremendous value in Smarty, and while I appreciate the power of XML and XSLT, I simply havent found a situation where it was the sweet spot in terms of functionality v. complexity.

Posted: Sat Oct 29, 2005 1:52 am
by n00b Saibot
Roja wrote: I simply havent found a situation where it was the sweet spot in terms of functionality v. complexity
i am sure you will find it in a short term.. ;) well it seems to partially push me into PHP's direction... ok...