-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.php
40 lines (32 loc) · 835 Bytes
/
test.php
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
<?
require_once "Mustache.php";
// The example template
$template=file_get_contents('test.mustache');
// (we are loading it from a mustache file...)
/* $template = 'Hello {{name}}
* You have just won ${{value}}!
* {{#in_ca}}
* Well, ${{taxed_value}}, after taxes.
* {{/in_ca}}';
*/
// Data structure backing the template
class Test extends Mustache {
public $name = "Chris";
public $value = 10000;
public function taxed_value() {
return $this->value - ($this->value * 0.4);
}
public $in_ca = true;
}
// Mustache class provides the render($string) method
$t = new Test;
echo $t->render($template);
// Generic class example:
/**
* $chris = new Chris;
* $m = new Mustache;
// render can be instantiated on any class
// without extending the mustache type
* echo $m->render($template, $chris);
*/
?>