template单元测试

This commit is contained in:
oldrind
2016-01-19 15:50:19 +08:00
parent ec667f8326
commit e17ec8f9ac
3 changed files with 29 additions and 36 deletions

View File

@@ -324,7 +324,10 @@ class TagLib
$_taglibs[$tag][0] = strlen(ltrim($this->tpl->config('taglib_begin'), '\\') . $tag);
$_taglibs[$tag][1] = strlen(ltrim($this->tpl->config('taglib_end'), '\\'));
}
$result['expression'] = trim(substr($str, $_taglibs[$tag][0], -$_taglibs[$tag][1]));
$result['expression'] = substr($str, $_taglibs[$tag][0], -$_taglibs[$tag][1]);
// 清除自闭合标签尾部/
$result['expression'] = rtrim($result['expression'], '/');
$result['expression'] = trim($result['expression']);
} elseif (empty($this->tags[$tag]) || !empty($this->tags[$tag]['attr'])) {
throw new Exception('_XML_TAG_ERROR_:' . $tag);
}

View File

@@ -253,7 +253,7 @@ class Cx extends Taglib
{
$name = !empty($tag['expression']) ? $tag['expression'] : $tag['name'];
$name = $this->autoBuildVar($name);
$parseStr = '<?php switch(' . $name . '): ?>' . $content . '<?php endswitch;?>';
$parseStr = '<?php switch(' . $name . '): ?>' . $content . '<?php endswitch; ?>';
return $parseStr;
}
@@ -270,20 +270,20 @@ class Cx extends Taglib
$flag = substr($value, 0, 1);
if ('$' == $flag || ':' == $flag) {
$value = $this->autoBuildVar($value);
$value = 'case ' . $value . ': ';
$value = 'case ' . $value . ':';
} elseif (strpos($value, '|')) {
$values = explode('|', $value);
$value = '';
foreach ($values as $val) {
$value .= 'case "' . addslashes($val) . '": ';
$value .= 'case "' . addslashes($val) . '":';
}
} else {
$value = 'case "' . $value . '": ';
$value = 'case "' . $value . '":';
}
$parseStr = '<?php ' . $value . ' ?>' . $content;
$isBreak = isset($tag['break']) ? $tag['break'] : '';
if ('' == $isBreak || $isBreak) {
$parseStr .= '<?php break;?>';
$parseStr .= '<?php break; ?>';
}
return $parseStr;
}