Adding examples.
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Comments extends Mustache {
|
||||||
|
public function title() {
|
||||||
|
return 'A Comedy of Errors';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<h1>{{title}}{{! just something interesting... or not... }}</h1>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<h1>A Comedy of Errors</h1>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<h1>{{header}}</h1>
|
||||||
|
{{#list}}
|
||||||
|
<ul>
|
||||||
|
{{#item}}
|
||||||
|
{{#current}}
|
||||||
|
<li><strong>{{name}}</strong></li>
|
||||||
|
{{/current}}
|
||||||
|
{{#link}}
|
||||||
|
<li><a href="{{url}}">{{name}}</a></li>
|
||||||
|
{{/link}}
|
||||||
|
{{/item}}
|
||||||
|
</ul>
|
||||||
|
{{/list}}
|
||||||
|
{{#empty}}
|
||||||
|
<p>The list is empty.</p>
|
||||||
|
{{/empty}}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Complex extends Mustache {
|
||||||
|
public $header = 'Colors';
|
||||||
|
|
||||||
|
public $item = array(
|
||||||
|
array('name' => 'red', 'current' => true, 'url' => '#Red'),
|
||||||
|
array('name' => 'green', 'current' => false, 'url' => '#Green'),
|
||||||
|
array('name' => 'blue', 'current' => false, 'url' => '#Blue'),
|
||||||
|
);
|
||||||
|
|
||||||
|
public function link() {
|
||||||
|
// Exploit the fact that the current iteration item is at the top of the context stack.
|
||||||
|
return $this->getVariable($current) != true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function list() {
|
||||||
|
return !($this->empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function empty() {
|
||||||
|
return count($this->item) === 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<h1>Colors</h1>
|
||||||
|
<ul>
|
||||||
|
<li><strong>red</strong></li>
|
||||||
|
<li><a href="#Green">green</a></li>
|
||||||
|
<li><a href="#Blue">blue</a></li>
|
||||||
|
</ul>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Simple extends Mustache {
|
||||||
|
public $name = "Chris";
|
||||||
|
public $value = 10000;
|
||||||
|
|
||||||
|
public function taxed_value() {
|
||||||
|
return $this->value - ($this->value * 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public $in_ca = true;
|
||||||
|
};
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Hello {{name}}
|
||||||
|
You have just won ${{value}}!
|
||||||
|
{{#in_ca}}
|
||||||
|
Well, ${{ taxed_value }}, after taxes.
|
||||||
|
{{/in_ca}}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
Hello Chris
|
||||||
|
You have just won $10000!
|
||||||
|
Well, $6000, after taxes.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Unescaped extends Mustache {
|
||||||
|
public $title = "Bear > Shark";
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<h1>{{{title}}}</h1>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<h1>Bear > Shark</h1>
|
||||||
Reference in New Issue
Block a user