2017 © Pedro Peláez
 

library leaf

PHP DOM Generator

image

undercloud/leaf

PHP DOM Generator

  • Sunday, April 10, 2016
  • by undercloud
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

leaf

PHP DOM Generator, (*1)

install

composer require unercloud/leaf, (*2)

simple example

    $l = new \Undercloud\Leaf();

    $l->el('html')
        ->el('body')
            ->el('h1#id.classname','Heading')->end
            ->el('p',array('class' => 'article'),'Lorem ipsum...')->end
            ->el('input:text',array('value'=>'text'))
        ->end
    ->end;

    echo $l;

constructor

    $l = new \Undercloud\Leaf(
        array(
            //format tree
            'format' => true,
            //indent in formatted tree, default two spaces
            'indent' => '  ',
            //define own single tags
            'selfclosing' => array(...)
        )
    );

methods

el - create element, (*3)

$l->el('tag')

or, (*4)

$l->el('tag','text')

or, (*5)

$l->el('tag',array $attr)

or, (*6)

$l->el('tag',array $attr,'text')

You can combine tag with #id and .classname shortcut e.g., (*7)

$l->el('span#id.classname.anotherclass')

Input[type] attr helper for button,checkbox,file,hidden,image,password,radio,reset,submit,text e.g., (*8)

$l->el('input:text')

Single attr helper for 'checked','disabled','readonly','required','multiple e.g., (*9)

$l->el('select:multiple')

text - create text node, (*10)

$l->text('any content')

raw - add raw data wihout escaping, (*11)

$l->raw('raw content')

end - close tag, (*12)

$l->end() // or $l->end

helpers

init - create instance, (*13)

Undercloud\Leaf::init($opt = array())

escape - escape special chars, (*14)

Undercloud\Leaf::escape($s)

The Versions

10/04 2016

dev-master

9999999-dev https://github.com/undercloud/leaf

PHP DOM Generator

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Avatar undercloud

generator html dom builder