Skip to content
This repository has been archived by the owner on Feb 12, 2018. It is now read-only.
/ TagMaker Public archive

A dynamic builder of HTML tag elements, for PHP (UNMAINTAINED)

License

Notifications You must be signed in to change notification settings

CarlosBonetti/TagMaker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project is DEPRECATED and not being maintained anymore.

TagMaker

A dynamic builder of tag elements

Quick Start

Instalation

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>'
$element->set_href('#');
$element->append_class('btn-large');
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');
$element->set_id('main-content');
$element->prepend_class('span6');

// 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).

Limitations

The actual version does not support multiple elements.

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

About

A dynamic builder of HTML tag elements, for PHP (UNMAINTAINED)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages