laperla / codeigniter-Blade

A port of Laravel's blade template system for CodeIgniter
54 stars 32 forks source link

This class is a port of Laravel's blade templating system for CodeIgniter framework.

It's compatible with Modular Extensions - HMVC and it uses the file cache for store compiled templates.

To install simply put the file into application/libraries and make sure that application/cache folder is writable.

By default template views must have .blade.php as extension. You can change this in $blade_ext class property.

Example usage in a controller:

class Test extends MX_Controller
{

    public function __construct()
    {
        parent::__construct();
        $this->load->library('blade');
    }   

    public function index()
    {
        // renders /views/test.blade.php or /modules/test/views/test.blade.php

        $this->blade->set('foo', 'bar')
            ->set('an_array', array(1, 2, 3, 4))
            ->append('an_array', 5)
            ->set_data(array('more' => 'data', 'other' => 'data'))
            ->render('test', array('message' => 'Hello World!'));
    }

}

See the docs on http://laravel.com/docs/views/templating