改进Template类import标签库

This commit is contained in:
thinkphp
2016-04-25 10:17:00 +08:00
parent 3e1e670de2
commit dd71f679ee
2 changed files with 8 additions and 8 deletions

View File

@@ -334,7 +334,7 @@ class Cx extends Taglib
} else {
$value = '\'' . $value . '\'';
}
switch($type) {
switch ($type) {
case 'equal':
$type = 'eq';
break;
@@ -524,7 +524,7 @@ class Cx extends Taglib
}
} else {
// 命名空间导入模式
$basepath = !empty($tag['basepath']) ? $tag['basepath'] : '/Public';
$basepath = !empty($tag['basepath']) ? $tag['basepath'] : '/public';
// 命名空间方式导入外部文件
$array = explode(',', $file);
foreach ($array as $val) {
@@ -689,10 +689,10 @@ class Cx extends Taglib
*/
public function _function($tag, $content)
{
$name = !empty($tag['name']) ? $tag['name'] : 'func';
$vars = !empty($tag['vars']) ? $tag['vars'] : '';
$call = !empty($tag['call']) ? $tag['call'] : '';
$use = ['&$' . $name];
$name = !empty($tag['name']) ? $tag['name'] : 'func';
$vars = !empty($tag['vars']) ? $tag['vars'] : '';
$call = !empty($tag['call']) ? $tag['call'] : '';
$use = ['&$' . $name];
if (!empty($tag['use'])) {
foreach (explode(',', $tag['use']) as $val) {
$use[] = '&' . ltrim(trim($val), '&');

View File

@@ -451,7 +451,7 @@ EOF;
{import file="base?ver=1.0" value="\$name.a" /}
EOF;
$data = <<<EOF
<?php if(isset(\$name['a'])): ?><script type="text/javascript" src="/Public/base.js?ver=1.0"></script><?php endif; ?>
<?php if(isset(\$name['a'])): ?><script type="text/javascript" src="/public/base.js?ver=1.0"></script><?php endif; ?>
EOF;
$cx->parseTag($content);
$this->assertEquals($content, $data);
@@ -460,7 +460,7 @@ EOF;
{import file="base" type="css" /}
EOF;
$data = <<<EOF
<link rel="stylesheet" type="text/css" href="/Public/base.css" />
<link rel="stylesheet" type="text/css" href="/public/base.css" />
EOF;
$cx->parseTag($content);
$this->assertEquals($content, $data);