Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 5407a001b2b430a0ac3ac177121c13d49507cadf 0 parents
Jamie Pittock authored
1  .gitignore
@@ -0,0 +1 @@
+.DS_Store
5 system/application/config/twig.php
@@ -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 system/application/libraries/Twig.php
@@ -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);
+ }
+}
+
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.