alexander-leitch / mustache-l4
PHP中Mustache实现的Laravel 4包装器。
v1.0
2017-03-02 14:15 UTC
Requires
- php: >=5.2.4
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-29 05:07:59 UTC
README
PHP中的Mustache实现。
使用方法
快速示例
<?php $m = new Mustache_Engine; echo $m->render('Hello {{planet}}', array('planet' => 'World!')); // "Hello World!"
更深入的示例 -- 这是标准的Mustache模板
Hello {{name}} You have just won ${{value}}! {{#in_ca}} Well, ${{taxed_value}}, after taxes. {{/in_ca}}
创建一个“视图”上下文对象 -- 它也可以是一个关联数组,但它们不擅长处理函数
<?php class Chris { public $name = "Chris"; public $value = 10000; public function taxed_value() { return $this->value - ($this->value * 0.4); } public $in_ca = true; }
并渲染它
<?php $m = new Mustache_Engine; $chris = new Chris; echo $m->render($template, $chris);
还有很多其他功能!
阅读Mustache.php文档以获取更多信息。