[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 Mustache.php 2 ============ 3 4 A [Mustache](http://mustache.github.com/) implementation in PHP. 5 6 [](https://packagist.org/packages/mustache/mustache) 7 [](http://travis-ci.org/bobthecow/mustache.php) 8 [](https://packagist.org/packages/mustache/mustache) 9 10 11 Usage 12 ----- 13 14 A quick example: 15 16 ```php 17 <?php 18 $m = new Mustache_Engine; 19 echo $m->render('Hello {{planet}}', array('planet' => 'World!')); // "Hello World!" 20 ``` 21 22 23 And a more in-depth example -- this is the canonical Mustache template: 24 25 ```html+jinja 26 Hello {{name}} 27 You have just won {{value}} dollars! 28 {{#in_ca}} 29 Well, {{taxed_value}} dollars, after taxes. 30 {{/in_ca}} 31 ``` 32 33 34 Create a view "context" object -- which could also be an associative array, but those don't do functions quite as well: 35 36 ```php 37 <?php 38 class Chris { 39 public $name = "Chris"; 40 public $value = 10000; 41 42 public function taxed_value() { 43 return $this->value - ($this->value * 0.4); 44 } 45 46 public $in_ca = true; 47 } 48 ``` 49 50 51 And render it: 52 53 ```php 54 <?php 55 $m = new Mustache_Engine; 56 $chris = new Chris; 57 echo $m->render($template, $chris); 58 ``` 59 60 61 And That's Not All! 62 ------------------- 63 64 Read [the Mustache.php documentation](https://github.com/bobthecow/mustache.php/wiki/Home) for more information. 65 66 67 See Also 68 -------- 69 70 * [Readme for the Ruby Mustache implementation](http://github.com/defunkt/mustache/blob/master/README.md). 71 * [mustache(5)](http://mustache.github.com/mustache.5.html) man page.
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |