FUEL CMS User Guide : Version 0.9.3


Parsing Overview

By default, FUEL disables PHP code from being saved in your module data (you must change the sanitize_input setting for the module). FUEL has implemented the Dwoo PHP 5 based templating system.

MY_Parser

FUEL overwrites the default CodeIgniter Parser library with the MY_Parser library to implement the expanded Dwoo templating syntax.

String Helper Functions

FUEL comes with the following string helper functions to help with parsing and converting from the Dwoo templating syntax:

Non-Namespaced Functions

The following are non-namespaced functions that can be used in your application and will be translated by the templating system.

Namespaced Functions

The following are namespaced functions that can be used in your application and will be translated by the templating system.

Note that several of the functions require an associative array paramter with the key="val" syntax.

Blocks

Tag pairs allow you to loop through arrays of data. The syntax requires an opening {my_var} and closing {/my_var} tag. For example:

$my_data = array();
$my_data[] = array('name' => 'Darth Vader', 'weapon' => 'light saber');
$my_data[] = array('name' => 'Han Solo', 'weapon' => 'blaster');
...
{loop $my_data}
	{$name} - {$weapon}
{loop}

You can also iterate over objects. For example, you may have a user model with some custom methods on it:

... 
$my_data = $this->user_model->find_all();

{foreach $my_data user}
	{$user->name} - {$user->weapon}
{/foreach}

The user part can actually be any value. You cannot insert outside variables inside a tag pair block.

Conditional Statements

FUEL also allows for php like conditional statements to be inserted into the view using {if ... }, {elseif ...} and {/if}. For example:

{$name='Darth Vader'}
{if $name == 'Darth Vader'}
I am your father.
{/if}

Creating your own tags

Dwoo provides several ways for it to extend it's templating syntax through plugins. The Dwoo folder to add your plugins is located at application/libraries/dwoo/plugins.