Skip to content

Commit

Permalink
CacheMacro: compatibility with Latte master
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 14, 2016
1 parent 62a27d9 commit 65cc60b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Bridges/CacheLatte/CacheMacro.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function nodeClosed(Latte\MacroNode $node)
/**
* @return void
*/
public static function initRuntime(Latte\Template $template)
public static function initRuntime(Latte\Runtime\Template $template)
{
if (!empty($template->global->cacheStack)) {
$file = (new \ReflectionClass($template))->getFileName();
Expand Down
2 changes: 1 addition & 1 deletion tests/Bridges.Latte/CacheMacro.cache.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ Assert::matchFile(
);
Assert::matchFile(
__DIR__ . '/expected/CacheMacro.cache.inc.phtml',
file_get_contents($latte->getCacheFile(__DIR__ . '/templates/include.cache.latte'))
file_get_contents($latte->getCacheFile(__DIR__ . strtr('/templates/include.cache.latte', '/', DIRECTORY_SEPARATOR)))
);
16 changes: 10 additions & 6 deletions tests/Bridges.Latte/expected/CacheMacro.cache.inc.phtml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<?php
// source: %A%

class Template%a% extends Latte\Template
class Template%a% extends Latte\Runtime\Template
{

function render()
function main()
{
%A%
// prolog Nette\Bridges\CacheLatte\CacheMacro
Nette\Bridges\CacheLatte\CacheMacro::initRuntime($this);

%A%
if (Nette\Bridges\CacheLatte\CacheMacro::createCache($this->global->cacheStorage, '%[\w]+%', $this->global->cacheStack)) {
?> <?php echo %a% ?>
Expand All @@ -18,7 +14,15 @@ class Template%a% extends Latte\Template
$_tmp = array_pop($this->global->cacheStack);
if (!$_tmp instanceof stdClass) $_tmp->end();
}
%A%
}


function prepare()
{
%A%
Nette\Bridges\CacheLatte\CacheMacro::initRuntime($this);
%A%
}

}
16 changes: 10 additions & 6 deletions tests/Bridges.Latte/expected/CacheMacro.cache.phtml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<?php
// source: %A%

class Template%a% extends Latte\Template
class Template%a% extends Latte\Runtime\Template
{

function render()
function main()
{
%A%
// prolog Nette\Bridges\CacheLatte\CacheMacro
Nette\Bridges\CacheLatte\CacheMacro::initRuntime($this);

%A%
Noncached content

Expand All @@ -28,7 +24,15 @@ Noncached content
$_tmp = array_pop($this->global->cacheStack);
if (!$_tmp instanceof stdClass) $_tmp->end();
}
%A%
}


function prepare()
{
%A%
Nette\Bridges\CacheLatte\CacheMacro::initRuntime($this);
%A%
}

}

0 comments on commit 65cc60b

Please sign in to comment.