CodeIgniter Blade Template Engine: Render templates in Blade format in CodeIgniter

Recommend this page to a friend!
  Info   View files Documentation   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2021-09-20 (27 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 23 This week: 9All time: 10,367 This week: 23Up
Version License PHP version Categories
codeigniter-blade-te 1.0The PHP License5PHP 5, Libraries, Templates
Description Author

This package can render templates in Blade format in CodeIgniter applications.

It provides a class library that can be loaded in a CodeIgniter application to render views.

The class can load a template script in the Blade format.

Then it compiles the template and caches the results of the compilation to avoid processing it again every time it needs to be used.

The class can set variables to replace in placeholders and configure the way the template is processed.

In the end the class can render the template and output the result as the output of the current PHP script.

Currently it supports marks of the Blade template format like:

- comments
- echo
- forelse
- empty
- includes
- layouts
- section_start
- section_end
- yields
- yield_sections
- extensions
- else
- unless
- endunless
- endforelse
- structure_openings
- structure_closings

Innovation Award
PHP Programming Innovation award nominee
September 2021
Nominee
Vote
Blade is a template engine included in the Laravel framework.

This package provides an alternative implementation of a template engine for the CodeIgniter framework that can render templates in Blade format.

Manuel Lemos
Picture of aidid alam
Name: aidid alam <contact>
Classes: 1 package by
Country: Bangladesh Bangladesh
Age: ???
All time rank: 442353 in Bangladesh Bangladesh
Week rank: 23 Up1 in Bangladesh Bangladesh Up
Innovation award
Innovation award
Nominee: 1x

Details

Blade Template in Codeigniter

This can render .blade.php in Codeinteger and can convert Strings into blade templating system.

  • This library follows HMVC
  • This has predefine cache for rendering files quickly
  • It supports: > comments, echos, forelse, empty, includes, layouts, section_start, section_end, yields, yield_sections, extensions, else, unless, endunless, endforelse, structure_openings, structure_closings

Installation

  • Download the package by clicking here
  • Extract the file to your project folder

Initialization

$this->load->library("bladeview");

Methods:

$this->bladeview->set('name', 'Jhon')
				->set('car_array', array("BMW", "FORD", "Mazda"))
				->append('car_array', "Volvo")
				->set_data(array('age' => 22, 'gender' => 'male'))
				->render('test', array('message' => 'Hello World!'));

Rendaring \*blade.php

$data = array(
	"foo" => "Hello",
	"bar" => "World",
);
$this->bladeview->render("test", $data);  //File extension *blade.php

Rendaring String

$string = "{{\$foo}} {{\$bar}}";
$data = array(
	"foo" => "<b>Hello</b>",
	"bar" => "World",
);
$this->bladeview->render($string, $data, false); //3rd parameter false is important

You can also save the blade output in a variable

$View_blade_output=$this->bladeview->render("test", $data,true,true);
$String_blade_output=$this->bladeview->render($string, $data,flase,true);

Example

class Welcome extends CI_Controller {
public function __construct() {
        parent::__construct();
		$this->load->library("bladeview");
	}

	public function renderView(){
		$data=array(
				"name"=>"Jhon",
				"age"=>21
			);
		$this->bladeview->render("test", $data);
	}

	public function renderString(){
		$data=array(
				"name"=>"Jhon",
				"age"=>21
			);
		$string="Hello I'm \{{$name}}. My age is \{{$age}}";
		$this->bladeview->render($string, $data,false);
	}
}

For more details please follow laravel blade documentaion.

  Files folder image Files  
File Role Description
Files folder imageapplication (1 directory)
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  application  
File Role Description
Files folder imagelibraries (1 file)

  Files folder image Files  /  application  /  libraries  
File Role Description
  Plain text file BladeView.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:23
This week:9
All time:10,367
This week:23Up
For more information send a message to info at phpclasses dot org.