Twig library for CodeIgniter 2.x

I’m trying to catch up with this social open source movement. I forked an existing CodeIgniter Twig integration library and added some changes to work with CodeIgniter 2.x.

Also I found a way map any CodeIgniter function to Twig like so.

$this->load->library('twig'); // load the Twig library
$this->load->helper('url'); // load the CodeIgniter URL helper
// map the base_url() function as a Twig function
$this->twig->add_function('base_url');

Then in your Twig view call the base_url() function like this

{{ base_url() }}

Head over to Github for more details.

In case you have no idea what I’m talking about. CodeIgniter is an excellent PHP framework and Twig is a Django style templating engine with inheritance for PHP.