Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/modifiers.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of tokkara  >  Simphple  >  examples/modifiers.php  >  Download  
File: examples/modifiers.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simphple
Process templates compiling into PHP code
Author: By
Last change:
Date: 2013-03-20 04:11
Size: 1,355 bytes
 

Contents

Class file image Download
<?php

include '../simphple/data_store/data_store.intfc.php';
include 
'../simphple/data_store/data_store_file.class.php';

include 
'../simphple/template/template_code.class.php';
include 
'../simphple/template/template.class.php';
include 
'../simphple/template/template_function.class.php';
include 
'../simphple/template/template_tools.class.php';

$dsf = new Sphp_Data_Store_File('cache/'truetrue);
$options = array('debug' => true'template_dir_path' => 'templates/''vars_without_keys' => Sphp_Template::VARS_WK_ENABLED_MODIFIERS);
$tpl = new Sphp_Template($dsf$options);

class 
Test{
    public static function 
uppercase($str){
        return 
strtoupper($str);
    }
    
    public function 
lowercase($str){
         return 
strtolower($str);
    }
}

$func1 = new Sphp_Template_Function('first_uppercase''ucfirst');
$func2 = new Sphp_Template_Function('static_method''Test::uppercase');
$func3 = new Sphp_Template_Function('method''lowercase', new Test());

$tpl->add_function($func1'f');
$tpl->add_function($func2'U');
$tpl->add_function($func3'l');

$tpl->add_variable('var1''first letter in uppercase.');
$tpl->add_variable('var2''aLL UPERcase.');
$tpl->add_variable('var3''All LOWERcase.');
$tpl->add_variable('var4''All LOWERcase, then the FIRST LETTER in uppercase.');
$tpl->display_file('modifiers.html');