Template Syntax Example
Variables are output with {{varname}}
# A simple variable, in Controller it's $data['variable'] {{variable}} # Using assoc array, $data['user']['fullname'] = 'DooPHP' {{user.fullname}} # Using functions/template tag with variables, case insensitive {{upper(variable)}} {{UPPER(user.fullname)}} # You can pass in arguments with the functions {{sample_with_args(variable, 'This is an argument')}}
Include a template file <!-- include 'file' -->
# Including a template file <!-- include 'template_name_without_dot_html' --> # Including a template file which is in a sub directory <!-- include 'folder/templatename' --> # Including a template file where the name is from a variable <!-- include "{{filename}}" -->
Looping a list <!-- loop users -->
# Looping a simple array $data['users']=array('john','doo','marie') <!-- loop users --> <li> {{users' value}} </li> <!-- endloop --> # Or a shorter alternative ... <!-- loop users --> <li> {{users' v}} </li> <!-- endloop --> # The loop name can be change ... <!-- loop users --> <li> {{loop' v}} </li> <!-- endloop --> # Functions can be used in loop <!-- loop users --> <li> {{upper(users' value)}} </li> <!-- endloop --> # Looping an assoc array $data['users']=array( 'john'=>array('name'=>'John Smith', 'gender'=>'male'), 'lee'=>array('name'=>'Bruce Lee', 'gender'=>'male') ); <!-- loop users --> <li> {{users' key}} fullname is {{users' value.name}} gender is {{users' value.gender}} </li> <!-- endloop -->
Using Objects in Template {{object.@property}}
# A simple object Doo::loadModel('SomeModel'); $obj = new SomeModel; $obj->fullname = 'My Cool Name'; $obj->SomeObject->weight = 88 $data['obj'] = $obj; {{obj.@fullname}} {{upper(obj.@fullname)}} {{obj.@SomeObject.@weight}} # Looping an array of Object <!-- loop users --> <li> Name: {{users' value.@fullname}} Gender: {{users' value.@gender}} Weight: {{users' v.@Physical.@weight}} Height: {{l' v.@Physical.@height}} </li> <!-- endloop -->BACK TO TOP