唉,更疑惑了,现在双层嵌套都没问题了。看来还是拼接语句没写对啊。
发现在这里发布了两个关于标签解析的问题,解决了问题之后发现还是常识性问题,不够仔细。
官网给的教程照搬是不能做到变量获取的,虽然手里有现成的标签库,照搬到现在才开始有点理解。拿官网给的input标签说吧;
第一步:定义input
'input'=>array('attr'=>'type,name,id,value','close'=>0), // input标签第二步:解析方法public function _input($attr,$content) {
$tag = $this->parseXmlAttr($attr,'input');
$name = $tag['name'];
$id = $tag['id'];
$type = $tag['type'];
$value = $this->autoBuildVar($tag['value']);
$str = "<input type='".$type."' id='".$id."' name='".$name."' value='".$value."' />";
return $str;
}关键就在第二步了,像$value的处理也是不能得到变量值的,这个帖子给了顿悟的感觉:http://www.thinkphp.cn/topic/8550.html。官网给的解答。然后参照yufucms的标签发现其实不用做autoBuildVar处理,输出原生代码就行了,如下:public function _input($attr,$content) {
$tag = $this->parseXmlAttr($attr,'input');
$name = $tag['name'];
$id = $tag['id'];
$type = $tag['type'];
$value = $tag['value'];
$str = "<input type='".$type."' id='".$id."' name='".$name."' value='<?php echo ".$value."?>' />";
return $str;
}第三步:模板输出<test:input type='text' id='test' name='mail' value='$value' />那个autoBuildVar可以让模板输出里的变量不用加$符。好吧。问题终于解决了。 最佳答案