Update README to reflect preferred mustache class implementation. Rendering arbitrary generic view class/array and template is secondary.
This commit is contained in:
+25
-16
@@ -26,6 +26,31 @@ And a more in-depth example--this is the canonical Mustache template:
|
||||
{{/in_ca}}
|
||||
|
||||
|
||||
Along with the associated Mustache class:
|
||||
|
||||
<?php
|
||||
class Chris extends Mustache {
|
||||
public $name = "Chris";
|
||||
public $value = 10000;
|
||||
|
||||
public function taxed_value() {
|
||||
return $this->value - ($this->value * 0.4);
|
||||
}
|
||||
|
||||
public $in_ca = true;
|
||||
}
|
||||
|
||||
|
||||
Render it like so:
|
||||
|
||||
<?php
|
||||
$c = new Chris;
|
||||
echo $chris->render($template);
|
||||
?>
|
||||
|
||||
|
||||
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:
|
||||
|
||||
<?php
|
||||
@@ -50,23 +75,7 @@ And render it:
|
||||
echo $m->render($template, $chris);
|
||||
?>
|
||||
|
||||
Here's the same thing, a different way:
|
||||
|
||||
<?php
|
||||
class Chris extends Mustache {
|
||||
public $name = "Chris";
|
||||
public $value = 10000;
|
||||
|
||||
public function taxed_value() {
|
||||
return $this->value - ($this->value * 0.4);
|
||||
}
|
||||
|
||||
public $in_ca = true;
|
||||
}
|
||||
|
||||
$c = new Chris;
|
||||
echo $chris->render($template);
|
||||
?>
|
||||
|
||||
|
||||
Known Issues
|
||||
|
||||
Reference in New Issue
Block a user