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
發布數50
最新版本名稱v2.14.2 (發布於 2022-08-23 09:07:12)
第一版名稱0.1 (發布於 2010-04-26 21:17:26)
創建於2010-03-19 10:58:58
推送於2023-06-11 02:16:53
最后一次提交
星數3.2k
關注者數115
派生數421
提交數858
已啟用問題?
問題數278
打開的問題數35
拉請求數54
打開的拉請求數5
關閉的拉請求數76
已啟用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

去到頂部