A dynamic builder of tag elements

Installs: 16

Dependents: 0

Stars: 3

Watchers: 1

Language: PHP

0.5.1 2013-04-25 00:48 UTC


This project is DEPRECATED and not being maintained anymore.

A dynamic builder of tag elements

Quick Start


Add to your composer.json:

"require": {
  "tagmaker/tagmaker": "~0.5"

Example of Use

$element = TagMaker::create('a', 'Link', array('class' => 'btn'));
echo $element; // Output: '<a class="btn">Link</a>'
echo $element; // Output: '<a href="#" class="btn btn-large">Link</a>'

CSS-Like element creation

$element = TagMaker::create('form.form-vertical#new-post[name=new-post,method=post]');
echo $element; // Output: '<form name="new-post" method="post" class="form-vertical" id="new-post"></form>'
$element = TagMaker::create('.row.span6#main {Lorem ipsum}');
echo $element; // Output: '<div class="row span6" id="main">Lorem ipsum</div>'

Magic methods for attributes manipulation

$element = TagMaker::create('.content', 'Lorem ipsum');

// Output: <div class="span6 content" id="main-content">Lorem ipsum</div>

Available magic methods for attribute manipulation are: append_{$attribute}($value), prepend_{$attribute}($value), set_{$attribute}($value), add_{$attribute}() and get_{$attribute}().

add_{$attribute}() tries to add an attribute to an Element, throwing a ExistentAttributeException if that attribute already exists.

set_{$attribute}() add an attribute to an Element, overriding it if already exists.

HTML Decoder

TagMaker provides a way to decodes single HTML elements and transforms it to a TagMaker\Element. Examples:

$element = TagMaker::decode('<div class="main" id="content">Lorem ipsum...</div>');
// Will create a TagMaker\Element based at the given HTML

Decoder does not support multiple elements (see Limitations).


The actual version does not support multiple elements.

Is pretended to support multiple elements (for decoding and creation) after 1.0 version.