File: example-webpage-new.php

package info (click to toggle)
raintpl 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 832 kB
  • sloc: php: 1,433; makefile: 8
file content (64 lines) | stat: -rw-r--r-- 1,602 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php

// include
require "library/Rain/autoload.php";

// namespace
use Rain\Tpl;

// conf
$config = array(
    "base_url"	=> null,
    "tpl_dir"	=> "templates/raintpl3/",
    "cache_dir"	=> "cache/",
    "debug"         => true // set to false to improve the speed
);

//use Rain;
Tpl::configure( $config );


// Add PathReplace plugin
Tpl::registerPlugin( new Rain\Tpl\Plugin\PathReplace() );


global $global_variable;
$global_variable = "I'm Global";

// set variables
$var = array(
    "variable"	=> "Hello",
    "version"	=> "3.0 Alpha",
    "menu"		=> array(
        array("name" => "Home", "link" => "index.php", "selected" => true ),
        array("name" => "FAQ", "link" => "index.php/FAQ/", "selected" => null ),
        array("name" => "Documentation", "link" => "index.php/doc/", "selected" => null )
    ),
    "week"		=> array( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ),
    "title"		=> "Rain TPL 3 - Easy and Fast template engine",
    "user"		=> array(
        array("name" => "Fede", "color" => "blue" ),
        array("name" => "Sheska", "color" => "red" ),
        array("name" => "Who", "color" => "yellow" ),
    ),
    "empty_array" => array(),
    "copyright" => "Copyright 2006 - 2012 Rain TPL<br>Project By Rain Team",

);

$test = function( $params ){
    $value = $params[0];
    return "Translate: <b>$value</b>";
};
// add a function
Tpl::registerTag( "({@.*?@})", "{@(.*?)@}", $test );



// draw
$tpl = new Tpl;
$tpl->assign( $var );
echo $tpl->draw( "page" );


// end