2017 © Pedro Peláez
 

library html

A library for creating Html via chainable PHP objects.

image

alexsasharegan/html

A library for creating Html via chainable PHP objects.

  • Sunday, September 25, 2016
  • by alexsasharegan
  • Repository
  • 1 Watchers
  • 1 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Html_lib

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

A library for creating Html via chainable PHP objects., (*2)


Methods

<?php

require_once 'path/to/Html_lib/Html_Autoloader.php';

// Instantiation
$div = new Html; # defaults to an empty 'div'
$button = new Html('button'); # specify the tagName
$p = new Html('p', 'This is a paragraph with some content.'); # specify inner element text

// Set element id
$appDiv = (new Html)->id('app');

// Adding classes
$div = new Html; # create a new div
$div->addClass('item'); # add class .item
$div->addClasses(['col-lg-3', 'col-md-4', 'col-sm-6']); # add multiple classes using an array

// Adding attributes
$input = new Html('input'); # create a new input
$input->addAttribute('type', 'text'); # add type="text" attr
$input->addAttributes(['required' => true, 'pattern' => '[a-zA-Z]']); # add an array of attrs

// Adding styles
$p = new Html('p'); # create a new paragraph
$p->addStyle('color', 'red'); # set color to red
$p->addStyles(['font-size' => '1.2em', 'text-transform' => 'uppercase',]); # set an array of inline styles

// Chaining
$parentDiv = (new Html)
    ->addStyle('color', 'red')
    ->addAttributes([ 'data-toggle' => 'tooltip', 'title' => 'This is my tooltip!' ])
    ->addClass('awesome');
echo $parentDiv;
// Outputs:
// 

// now lets give it child elements $parentDiv->newChild('h3', 'Chaining'); $parentDiv->newChild('p', 'This is some awesome chaining!'); $childForm = $parentDiv->newChild('form')->addAttribute('method', 'POST'); $childForm->newChild('input')->addAttribute('type', 'text'); $childForm->newChild('button', 'Send')->addAttribute('type', 'submit'); echo $parentDiv; // Outputs: //
//

Chaining

//

This is some awesome chaining!, (*3)

//
// // //
//
// Static method element creation echo Html::createElement('h1', 'Awesome, right?', [ 'style' => 'font-family:Monaco;', 'class' => 'awesome heading', ]); // Outputs: //

Awesome, right?

The Versions

25/09 2016

dev-master

9999999-dev https://github.com/alexsasharegan/Html_lib

A library for creating Html via chainable PHP objects.

  Sources   Download

MIT

The Requires

 

by Alex Regan

html

08/09 2016

1.1.1

1.1.1.0 https://github.com/alexsasharegan/Html_lib

A library for creating Html via chainable PHP objects.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Alex Regan

html

06/09 2016

1.1.0

1.1.0.0 https://github.com/alexsasharegan/Html_lib

A library for creating Html via chainable PHP objects.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Alex Regan

html

06/09 2016

1.0.0

1.0.0.0 https://github.com/alexsasharegan/Html_lib

A library for creating Html via chainable PHP objects.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Alex Regan

html