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文档了解更多信息。 另见 Ruby Mustache实施的自述。 胡子(5)手册页。
主要指標 概覽 名稱與所有者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. 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 Readme for the Ruby Mustache implementation. mustache(5) man page.
計算機及開源技朮研究與分享。 關於 條款和條件 隱私政策 聯絡我們 百度FEX 淘系前端團隊 騰訊AlloyTeam 凹凸實驗室 學習強國 中國科技網 上海技朮交易所 中小企業信息網 WorldLink资源网 粤ICP13055436号 粤公网安备 44010602007678号 Make with by Osdir lab. const ctx = document.getElementById('myChart').getContext('2d'); const myChart = new Chart(ctx, { type: "line", data:{ labels: [], datasets: [] }, options: { responsive: true, hoverMode: "index", stacked: false, animations: { tension: { duration: 1000, easing: 'linear', from: 1, to: 0, loop: true }, scales: { y: { // defining min and max so hiding the dataset does not change scale range min: 0, max: 100 } } }, }, plugins:[] }); $(function () { // 解析Markdown $('.markdown-body').each(function (i, block) { if ($(block).attr("parsed") == undefined) { // console.log($(block)) let content = DOMPurify.sanitize($(block).html()); $(block).html(content) $(block).find('pre code').each(function (i, block) { Prism.highlightElement(block); }); $(block).attr("parsed", "true") } }); UIkit.util.on(".js-product-switcher", "show", function() { UIkit.update() }); $.qAjax("/ajax/phc?id=1086", { qKey: 'chart', qTimeout: 400, success: function (res) { // console.log(res) if (res.code == 0) { var choiceContainer = $("#choices"); var datasets = res.data.datasets // console.log(datasets) myChart.data.labels = res.data.label $.each(datasets, function(key, val) { // console.log("key=", key + " val=", val) if (key == 0) { choiceContainer.append("<br/><label><input class='uk-checkbox' type='checkbox' name='w" + key + "' checked='checked' data-selection-id=" + key + "></input> " + val.label + "</label>"); } else { choiceContainer.append("<br/><label><input class='uk-checkbox' type='checkbox' name='w" + key + "' data-selection-id=" + key + "></input> " + val.label + "</label>"); } }); choiceContainer.find("input").click(plotAccordingToChoices); function plotAccordingToChoices() { var data = []; choiceContainer.find("input:checked").each(function () { var key = $(this).data('selection-id'); if (key >= 0 && datasets[key]) { data.push(datasets[key]); } }); // console.log("plot...",data) myChart.data.datasets = data myChart.update(); } plotAccordingToChoices(); } else { if (res.msg) UIkit.notification({ message: res.msg, status: 'warning', pos: 'top-right', timeout: 5000 }); // swal({ // text: res.msg, // icon: "warning", // button: "确定", // }); } } }); }) (function($) { "use strict"; var relatedUrl = "/ajax/related/mustache-php"; var ownerUrl = "/ajax/owner/mustache-php/MDQ6VXNlcjUzNjYw"; var oid = "MDQ6VXNlcjUzNjYw"; $(function () { function load(url, key, element) { element.ajaxStart(); $.qAjax(url, { qKey: key, qTimeout: 400, success: function (data) { element.ajaxComplete(); element.empty().append($(data.content)); if (data.total > 0) { if (url.includes("owner")) { $('.owner-repos-count').text(data.total); $('.tab-owner-repos-count').text(data.total); } } } }); } load(relatedUrl, 'related', $('#related-list')); if(oid) { load(ownerUrl, 'projects', $('#projects-list')); } $('#projects-list').on('click', '.pagination a', function () { load($(this).attr('href'), $('#projects-list')); return false; }); }); })(jQuery);