Page 1 of 1

Tag libraries

Posted: Fri Aug 10, 2007 4:46 pm
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?

Posted: Fri Aug 10, 2007 5:22 pm
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.

Posted: Fri Aug 10, 2007 5:33 pm
by alex.barylski

Posted: Fri Aug 10, 2007 6:03 pm
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 :)

Posted: Fri Aug 10, 2007 6:41 pm
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.