Re: Validation framework
Posted: Mon Nov 24, 2008 2:14 pm
The base Skeleton tag renderer is essentially identical, but a class (there are classes for all the other HTML tags that inherit this).
I think the main difference is your selfClosing vs just passing content to determine when to generate a closing tag. I think you can pass strings or objects as content. I also think you can pass content in the attributes array as 'content' like your 'innerhtml' (better name!)
Code: Select all
class A_Html_Tag {
/*
* $tag - name of tag
* $attr - array of attributes
* $content - determines if the tag has a closing tag - defined yes, null no
* - a string, an object with a render() method or an array containing any mix of those
* e.g. render('div', array('id'=>'foo'), 'bar') generates <div id="foo">bar</div>
* e.g. render('img', array('src'=>'foo.jpg', 'alt'=>'bar')) generates <img src="foo.jpg" alt="bar"/>
*/
public function render($tag, $attr=array(), $content=null) {
}
public function __toString() {
$this->render();
}
}