Tag libraries

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Tag libraries

Post by Chris Corbyn »

Does anyone know if the equivalent of JSP tag libraries has been written for PHP?

It's just XML which invokes tag handling classes as it's parsed. For example:

Code: Select all

<mytag:foo thing="bar" />
Would be parsed by a class like (in Java of course):

Code: Select all

class FooTag extends SomeAbstractTag {
  protected $thing;
  public function setThing($thing) {
    $this->thing = $thing;
  }
  public function getThing() {
    return $this->thing;
  }
  public function doStartTag() {
    echo "Tag encounted with thing=" . $this->getThing();
  }
  public function doEndTag() {
    echo "Tag closed";
  }
}
I could write something myself, but the logic gets complex when you start dealing with nested tags and re-evaluating markup so I'm just curious if anyone knows of anything like this already?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

The closest thing to that kind of parser would be the one in WACT I think. But I haven't looked at that for quite a while.
(#10850)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Is it just me, or are there two prado's for PHP?

http://www.pradosoft.com/

EDIT | Nope, what prado has is not what I'm looking for. I'll have a gander at ~arborint's suggestion :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

WACT looks promising :) I'm looking for code examples more than anything else, since my colleague is working on something similar but I'm not convinced it's been implemented as well as it could have been.
Post Reply