Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Pittock committed Nov 1, 2009
0 parents commit 5407a00
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
5 changes: 5 additions & 0 deletions system/application/config/twig.php
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

$config['template_dir'] = APPPATH.'views';

$config['cache_dir'] = APPPATH.'cache/twig';
43 changes: 43 additions & 0 deletions system/application/libraries/Twig.php
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php if (!defined('BASEPATH')) {exit('No direct script access allowed');}

class Twig
{
private $CI;
private $_twig;
private $_template_dir;
private $cache_dir;

/**
* Constructor
*
*/
function __construct()
{
$this->CI =& get_instance();
$this->CI->config->load('twig');

ini_set('include_path',
ini_get('include_path') . PATH_SEPARATOR . APPPATH . 'libraries/Twig');
require_once (string) "Autoloader" . EXT;
log_message('debug', "Twig Autoloader Loaded");

Twig_Autoloader::register();

$this->_template_dir = $this->CI->config->item('template_dir');
$this->_cache_dir = $this->CI->config->item('cache_dir');

$loader = new Twig_Loader_FileSystem($this->_template_dir, $this->_cache_dir);

$this->_twig = new Twig_Environment($loader);

}

public function renderFile($template, $data = array()) {

$template = $this->_twig->loadTemplate($template);

return $template->render($data);
}
}

?>

0 comments on commit 5407a00

Please sign in to comment.