PHPTal

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

PHPTal

Post 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?
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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 :)
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post 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.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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...
Post Reply