Merge remote-tracking branch 'Aijoona/master' into dev

This commit is contained in:
Justin Hileman
2012-01-15 09:47:11 -08:00
+50 -43
View File
@@ -9,73 +9,80 @@ Usage
A quick example: A quick example:
<?php ```php
include('Mustache.php'); <?php
$m = new Mustache; include('Mustache.php');
echo $m->render('Hello {{planet}}', array('planet' => 'World!')); $m = new Mustache;
// "Hello World!" echo $m->render('Hello {{planet}}', array('planet' => 'World!'));
?> // "Hello World!"
```
And a more in-depth example--this is the canonical Mustache template: And a more in-depth example--this is the canonical Mustache template:
Hello {{name}} ```
You have just won ${{value}}! Hello {{name}}
{{#in_ca}} You have just won ${{value}}!
Well, ${{taxed_value}}, after taxes. {{#in_ca}}
{{/in_ca}} Well, ${{taxed_value}}, after taxes.
{{/in_ca}}
```
Along with the associated Mustache class: Along with the associated Mustache class:
<?php ```php
class Chris extends Mustache { <?php
public $name = "Chris"; class Chris extends Mustache {
public $value = 10000; public $name = "Chris";
public $value = 10000;
public function taxed_value() { public function taxed_value() {
return $this->value - ($this->value * 0.4); return $this->value - ($this->value * 0.4);
}
public $in_ca = true;
} }
public $in_ca = true;
}
```
Render it like so: Render it like so:
<?php ```php
$chris = new Chris; <?php
echo $chris->render($template); $chris = new Chris;
?> echo $chris->render($template);
```
Here's the same thing, a different way: Here's the same thing, a different way:
Create a view object--which could also be an associative array, but those don't do functions quite as well: Create a view object--which could also be an associative array, but those don't do functions quite as well:
<?php ```php
class Chris { <?php
public $name = "Chris"; class Chris {
public $value = 10000; public $name = "Chris";
public $value = 10000;
public function taxed_value() {
return $this->value - ($this->value * 0.4);
}
public $in_ca = true;
}
?>
public function taxed_value() {
return $this->value - ($this->value * 0.4);
}
public $in_ca = true;
}
```
And render it: And render it:
<?php ```php
$chris = new Chris; <?php
$m = new Mustache; $chris = new Chris;
echo $m->render($template, $chris); $m = new Mustache;
?> echo $m->render($template, $chris);
```
Known Issues Known Issues