自定义标签
namespace Think\Template\Taglib;
use Think\Template\TagLib;
Class Test extends TagLib{
protected $tags = array(
//定义标签
'input' => array('attr'=>'type,name,id,value'),
'textarea' => array('attr'=>'name,id'),
)
//input标签解析
public function _input($tag,$content) {
$name = $tag['name'];
$id = $tag['id'];
$str = "<input type='".$type."' id = '".$id."' />"
return $str;
}
}
这样自定义标签就定义好了,可以在模板中<test:input>输出对应的代码。