Skip to content

Commit

Permalink
Twig 1.27+ support (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
SCIF authored and barryvdh committed Dec 25, 2016
1 parent efda1a6 commit fda1efa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"require": {
"php": ">=5.4.0",
"twig/twig": "~1.15|~2.0",
"twig/twig": "~1.27|~2.0",
"illuminate/support": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*",
"illuminate/view": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function get($path, array $data = [])
*/
protected function handleTwigError(Twig_Error $ex)
{
$templateFile = $ex->getTemplateFile();
$templateFile = $ex->getSourceContext()->getPath();
$templateLine = $ex->getTemplateLine();

if ($templateFile && file_exists($templateFile)) {
Expand Down
10 changes: 6 additions & 4 deletions src/Twig/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace TwigBridge\Twig;

use Twig_LoaderInterface;
use Twig_SourceContextLoaderInterface;
use Twig_Error_Loader;
use Twig_ExistsLoaderInterface;
use InvalidArgumentException;
Expand All @@ -21,7 +21,7 @@
/**
* Basic loader using absolute paths.
*/
class Loader implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
class Loader implements Twig_SourceContextLoaderInterface, Twig_ExistsLoaderInterface
{
/**
* @var \Illuminate\Filesystem\Filesystem
Expand Down Expand Up @@ -116,9 +116,11 @@ public function exists($name)
/**
* {@inheritdoc}
*/
public function getSource($name)
public function getSourceContext($name)
{
return $this->files->get($this->findTemplate($name));
$path = $this->findTemplate($name);

return new \Twig_Source($this->files->get($path), $name, $path);
}

/**
Expand Down

0 comments on commit fda1efa

Please sign in to comment.