PHP DOM Generator

dev-master 2016-04-10 05:41 UTC

This package is auto-updated.

Last update: 2024-03-28 06:40:47 UTC


README

PHP DOM Generator

##install composer require unercloud/leaf

##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

$l->el('tag')

or

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

or

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

or

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

You can combine tag with #id and .classname shortcut e.g.

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

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

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

Single attr helper for 'checked','disabled','readonly','required','multiple e.g.

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

text - create text node

$l->text('any content')

raw - add raw data wihout escaping

$l->raw('raw content')

end - close tag

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

##helpers init - create instance

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

escape - escape special chars

Undercloud\Leaf::escape($s)