Added syntax highlight.
This commit is contained in:
+36
-29
@@ -9,27 +9,31 @@ 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
|
||||||
|
class Chris extends Mustache {
|
||||||
public $name = "Chris";
|
public $name = "Chris";
|
||||||
public $value = 10000;
|
public $value = 10000;
|
||||||
|
|
||||||
@@ -38,23 +42,26 @@ Along with the associated Mustache class:
|
|||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
class Chris {
|
||||||
public $name = "Chris";
|
public $name = "Chris";
|
||||||
public $value = 10000;
|
public $value = 10000;
|
||||||
|
|
||||||
@@ -63,19 +70,19 @@ Create a view object--which could also be an associative array, but those don't
|
|||||||
}
|
}
|
||||||
|
|
||||||
public $in_ca = true;
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user