undercloud / leaf
PHP DOM 生成器
dev-master
2016-04-10 05:41 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-08-28 07:35:49 UTC
README
PHP DOM 生成器
##安装 composer require unercloud/leaf
##简单示例
$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;
##构造函数
$l = new \Undercloud\Leaf( array( //format tree 'format' => true, //indent in formatted tree, default two spaces 'indent' => ' ', //define own single tags 'selfclosing' => array(...) ) );
##方法 el - 创建元素
$l->el('tag')
或
$l->el('tag','text')
或
$l->el('tag',array $attr)
或
$l->el('tag',array $attr,'text')
您可以将标签与 #id 和 .classname 快捷方式结合使用,例如。
$l->el('span#id.classname.anotherclass')
Input[type] 属性辅助器用于按钮、复选框、文件、隐藏、图片、密码、单选框、重置、提交、文本等。
$l->el('input:text')
单个属性辅助器用于 'checked'、'disabled'、'readonly'、'required'、'multiple' 等。
$l->el('select:multiple')
text - 创建文本节点
$l->text('any content')
raw - 添加未转义的原始数据
$l->raw('raw content')
end - 关闭标签
$l->end() // or $l->end
##辅助函数 init - 创建实例
Undercloud\Leaf::init($opt = array())
escape - 转义特殊字符
Undercloud\Leaf::escape($s)