Adding examples.

This commit is contained in:
Justin Hileman
2010-03-30 14:57:18 -04:00
parent a51146f5e2
commit 5e99b15252
12 changed files with 82 additions and 0 deletions
+16
View File
@@ -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}}
+24
View File
@@ -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;
}
}
+6
View File
@@ -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>