- PHP 5.2 or greater
- CodeIgniter 2.1+
Copy application/libraries/Template.php
to your project folder.
Make sure that your application/cache
folder have permissions to write (0755).
Add template
to libraries autoload or load this library in your controller.
###Sample variables ####Controller:
<?php
public function index()
{
$data = array('sample_var' => 'SAMPLE_VAR', 'var_with_html' => 'Var with <b>HTML</b>');
$this->template->parse_view('welcome_message.php', $data);
}
?>
####View: {{sample_var}} {{!var_with_html}}
####Output: SAMPLE_VAR Var with HTML ###Boolean variables ####Controller: true); $this->template->parse_view('welcome_message.php', $data); } ?> ####View: ((ture_var))You can see this text, because ture_var set in TRUE ((/ture_var)) ((!ture_var))And you can not see this text, because ture_var not equal to FALSE((/ture_var)) ####Output: You can see this text, because ture_var set in TRUE! ###Arrays ####Controller: 'John', 'age' => 41); $data['list'][] = array('name' => 'Andy', 'age' => 17); $data['list'][] = array('name' => 'Dany', 'age' => 28); $this->template->parse_view('welcome_message.php', $data); } ?> ####View: [[list]]
NAME: {{list.name}}, AGE: {{list.age}}
[[/list]]; ####Output: NAME: John, AGE: 41 NAME: Andy, AGE: 17 NAME: Dany, AGE: 28