Skip to content

Commit

Permalink
Revert "single filterinfo instance"
Browse files Browse the repository at this point in the history
This reverts commit b8af9fe.
  • Loading branch information
dg committed May 13, 2016
1 parent 0ef441a commit be4bd5b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/Latte/Macros/BlockMacros.php
Expand Up @@ -125,7 +125,7 @@ public function macroInclude(MacroNode $node, PhpWriter $writer)
}

if ($node->modifiers) {
return $writer->write("ob_start(function () {}); $cmd; \$this->global->fi->contentType = %var; echo %modifyFI(ob_get_clean())", $node->context[0]);
return $writer->write("ob_start(function () {}); $cmd; \$_fi = new LR\\FilterInfo(%var); echo %modifyFI(ob_get_clean())", $node->context[0]);
} else {
return $writer->write($cmd);
}
Expand Down Expand Up @@ -250,7 +250,7 @@ public function macroBlock(MacroNode $node, PhpWriter $writer)

$include = 'call_user_func(reset($this->blockQueue[%var]), ' . (($node->name === 'snippet' || $node->name === 'snippetArea') ? '$this->params' : 'get_defined_vars()') . ')';
if ($node->modifiers) {
$include = "ob_start(function () {}); $include; \$this->global->fi->contentType = 'html'; echo %modifyFI(ob_get_clean())";
$include = "ob_start(function () {}); $include; \$_fi = new LR\\FilterInfo('html'); echo %modifyFI(ob_get_clean())";
}

if ($node->name === 'snippet') {
Expand Down Expand Up @@ -340,7 +340,7 @@ public function macroBlockEnd(MacroNode $node, PhpWriter $writer)
return ' '; // consume next new line

} elseif ($node->modifiers) { // anonymous block with modifier
return $writer->write('$this->global->fi->contentType = %var; echo %modifyFI(ob_get_clean())', $node->context[0]);
return $writer->write('$_fi = new LR\FilterInfo(%var); echo %modifyFI(ob_get_clean())', $node->context[0]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Latte/Macros/CoreMacros.php
Expand Up @@ -212,7 +212,7 @@ public function macroInclude(MacroNode $node, PhpWriter $writer)
$noCheck ? NULL : implode('', $node->context)
);
if ($node->modifiers) {
return $writer->write('ob_start(function () {}); %raw; $this->global->fi->contentType = %var; echo %modifyFI(ob_get_clean())', $code, $node->context[0]);
return $writer->write('ob_start(function () {}); %raw; $_fi = new LR\FilterInfo(%var); echo %modifyFI(ob_get_clean())', $code, $node->context[0]);
} else {
return $code;
}
Expand Down Expand Up @@ -254,7 +254,7 @@ public function macroCaptureEnd(MacroNode $node, PhpWriter $writer)
$body = $node->context[0] === Latte\Engine::CONTENT_HTML
? "ob_get_length() ? new LR\\Html(ob_get_clean()) : ob_get_clean()"
: 'ob_get_clean()';
return $writer->write("\$this->global->fi->contentType = %var; %raw = %modifyFI($body)", $node->context[0], $node->data->variable);
return $writer->write("\$_fi = new LR\\FilterInfo(%var); %raw = %modifyFI($body)", $node->context[0], $node->data->variable);
}


Expand Down
4 changes: 2 additions & 2 deletions src/Latte/PhpWriter.php
Expand Up @@ -110,7 +110,7 @@ public function formatModifiers($var, $fi = FALSE)
$tokens = $this->preprocess($tokens);
$tokens = $this->modifierPass($tokens, $var, $fi);
if ($fi) {
$tokens->prepend('LR\Filters::convertTo($this->global->fi, ' . var_export(implode('', $this->context), TRUE) . ', ')
$tokens->prepend('LR\Filters::convertTo($_fi, ' . var_export(implode('', $this->context), TRUE) . ', ')
->append(')');
}
$tokens = $this->quotingPass($tokens);
Expand Down Expand Up @@ -425,7 +425,7 @@ public function modifierPass(MacroTokens $tokens, $var, $fi = FALSE)
} else {
$name = strtolower($tokens->currentValue());
$res->prepend($fi
? '$this->filters->contentFilter('. var_export($name, TRUE) . ', $this->global->fi, '
? '$this->filters->contentFilter('. var_export($name, TRUE) . ', $_fi, '
: 'call_user_func($this->filters->' . $name . ', '
);
$inside = TRUE;
Expand Down
1 change: 0 additions & 1 deletion src/Latte/Template.php
Expand Up @@ -59,7 +59,6 @@ public function __construct(Engine $engine, array $params, Filters $filters, arr
$this->filters = $filters;
$this->name = $name;
$this->global = (object) $providers;
$this->global->fi = new Runtime\FilterInfo;
foreach ($this->blocks as $nm => $method) {
$this->blockQueue[$nm][] = [$this, $method];
}
Expand Down

0 comments on commit be4bd5b

Please sign in to comment.