Fix tabulation

Add 'macro' namespace in import support
This commit is contained in:
bzick 2013-02-23 16:35:11 +04:00
parent b3480e820b
commit 7631e3508d
7 changed files with 238 additions and 221 deletions

View File

@ -634,6 +634,11 @@ class Compiler {
return "echo ".$scope["filter"].";"; return "echo ".$scope["filter"].";";
} }
/**
* @param Tokenizer $tokens
* @param Scope $scope
* @return string
*/
public static function captureOpen(Tokenizer $tokens, Scope $scope) { public static function captureOpen(Tokenizer $tokens, Scope $scope) {
if($tokens->is("|")) { if($tokens->is("|")) {
$scope["value"] = $scope->tpl->parseModifier($tokens, "ob_get_clean()"); $scope["value"] = $scope->tpl->parseModifier($tokens, "ob_get_clean()");
@ -650,6 +655,14 @@ class Compiler {
return $scope["var"]." = ".$scope["value"].";"; return $scope["var"]." = ".$scope["value"].";";
} }
/**
* Tag {cycle}
*
* @param Tokenizer $tokens
* @param Template $tpl
* @return string
* @throws ImproperUseException
*/
public static function tagCycle(Tokenizer $tokens, Template $tpl) { public static function tagCycle(Tokenizer $tokens, Template $tpl) {
$exp = $tpl->parseExp($tokens, true); $exp = $tpl->parseExp($tokens, true);
if($tokens->valid()) { if($tokens->valid()) {
@ -679,6 +692,9 @@ class Compiler {
} }
if($tokens->is(T_AS)) { if($tokens->is(T_AS)) {
$alias = $tokens->next()->get(Tokenizer::MACRO_STRING); $alias = $tokens->next()->get(Tokenizer::MACRO_STRING);
if($alias === "macro") {
$alias = "";
}
$tokens->next(); $tokens->next();
} else { } else {
$alias = ""; $alias = "";
@ -697,10 +713,11 @@ class Compiler {
$tpl->addDepend($donor); $tpl->addDepend($donor);
} }
return ''; return '';
} }
/** /**
* Declare or invoke macros * Define macro
* *
* @param Tokenizer $tokens * @param Tokenizer $tokens
* @param Scope $scope * @param Scope $scope