The core classes are meant to be extended and used to create complex patterns. All classes implement tree-crawling properties such as the following :, (*2)
You can see examples implementations in the examples folder., (*4)
Properties injection
If your class use properties that are at meant to be added to the final array of attributes, you can inject them using the injectProperties method. Say you have a Link class that has an url property, you can overwrite the method like this, and the $this->url will get added in the href attribute :, (*5)
Or if the property bears the property's name you can simply add it to the array of automatically injected properties :, (*6)
protected $injectedProperties = array('href', 'title');
// Will be added as href="#foo"
protected $href = '#foo';
// Will be added as title="title"
protected $title = 'title';
Altering a precreated tree
HtmlObject allows to use the open and close to open tags but when your tag has children you sometimes want to open the tree at a particular point to inject data at runtime, you can do it like this :, (*7)
$mediaObject = Element::div([
'title' => Element::h2('John Doe'),
'body' => Element::div(),
]);
echo $mediaObject->openOn('body').'My name is John Doe'.$mediaObject->close();
<div>
<h2>John Doe</h2>
<div>My name is John Doe</div>
</div>
The Versions
04/062013
dev-master
9999999-dev
A set of classes to create and manipulate HTML objects abstractions, forked from Anahkiasen's html-object.