mustache.php

A Mustache implementation in PHP.

  • 所有者: bobthecow/mustache.php
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

Mustache.php

PHP中的 Mustache 实现。

用法

一个简单的例子:

 <?php
$ m = new Mustache_Engine;
echo'm-> render('Hello {{planet}}',array('planet'=>'World!')); //“你好,世界!”
 

更深入的例子 - 这是规范的胡须模板:

  Hello {{name}}
您刚赢得{{value}}美元!
{{#in_ca}}
恩,{taxed_value}}美元,税后。
{{/in_ca}}
 

创建一个视图“上下文”对象 - 也可以是一个关联数组,但那些函数并不如此:

 <?php
克里斯{
    public $ name =“Chris";
    public $ value = 10000;

    public function taxed_value(){
        返回$ this->值 - ($ this->值* 0.4);
    }

    public $ in_ca = true;
}
 

并呈现它:

 <?php
$ m = new Mustache_Engine;
$ chris = new Chris;
echo $ m-> render($ template,$ chris);
 

这并非全部!

阅读 Mustache.php文档了解更多信息。

另见

主要指标

概览
名称与所有者bobthecow/mustache.php
主编程语言PHP
编程语言PHP (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2010-03-19 10:58:58
推送于2025-06-28 18:37:45
最后一次提交
发布数52
最新版本名称v3.0.0 (发布于 2025-06-28 14:29:02)
第一版名称0.1 (发布于 2010-04-26 21:17:26)
用户参与
星数3.3k
关注者数114
派生数436
提交数0.9k
已启用问题?
问题数283
打开的问题数31
拉请求数60
打开的拉请求数2
关闭的拉请求数82
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?

Mustache.php

A Mustache implementation in PHP.

Package version
Build status
StyleCI
Monthly downloads

Usage

A quick example:

<?php
$m = new Mustache_Engine;
echo $m->render('Hello {{planet}}', array('planet' => 'World!')); // "Hello World!"

And a more in-depth example -- this is the canonical Mustache template:

Hello {{name}}
You have just won {{value}} dollars!
{{#in_ca}}
Well, {{taxed_value}} dollars, after taxes.
{{/in_ca}}

Create a view "context" object -- which could also be an associative array, but those don't do functions quite as well:

<?php
class Chris {
    public $name  = "Chris";
    public $value = 10000;

    public function taxed_value() {
        return $this->value - ($this->value * 0.4);
    }

    public $in_ca = true;
}

And render it:

<?php
$m = new Mustache_Engine;
$chris = new Chris;
echo $m->render($template, $chris);

And That's Not All!

Read the Mustache.php documentation for more information.

See Also