Skip to content

Commit

Permalink
Init submodule and fixed Twig.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik committed Mar 2, 2010
1 parent e821cfa commit edba33c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "libraries/Twig"]
path = libraries/Twig
url = git://github.com/fabpot/Twig.git
1 change: 1 addition & 0 deletions libraries/Twig
Submodule Twig added at d2b447
13 changes: 7 additions & 6 deletions template/view/adapter/Twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@

namespace li3_twig\template\view\adapter;

use \lithium\template\view\Renderer;

/**
* View adapter for Twig templating. http://twig-project.org
*
* @see lithium\template\view\Renderer
*/

class Twig extends Renderer
class Twig extends \lithium\template\view\Renderer
{
/**
* @var Twig_Environment
Expand All @@ -33,14 +31,15 @@ public function __construct($config = array())
{
parent::__construct($config);

Libraries::add('Twig', array(
\lithium\core\Libraries::add('Twig', array(
'path' => realpath(__DIR__ . '/../../../libraries/Twig/lib/Twig'),
'prefix' => 'Twig_',
'loader' => 'Twig_Autoloader::autoload',
));

$this->_environment = new \Twig_Environment(new \Twig_Loader_Filesystem(array()), array(
'cache' => LITHIUM_APP_PATH . '/resources/tmp/cache/templates',
'cache' => null,//LITHIUM_APP_PATH . '/resources/tmp/cache/templates',
'debug' => true,
'auto_reloader' => true,
));
}
Expand All @@ -55,6 +54,8 @@ public function __construct($config = array())
*/
public function render($paths, $data = array(), $options = array())
{
$this->_context = $options['context'] + $this->_context;

$directories = array_map(function ($item) {
return dirname($item);
}, $paths);
Expand All @@ -66,6 +67,6 @@ public function render($paths, $data = array(), $options = array())

//Because $this is not availible in the Twig template view is used as
//an substitute.
return $template->render((array) $data + array('view' => $this));
return $template->render((array) $data + array('this' => $this));
}
}

0 comments on commit edba33c

Please sign in to comment.