• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Mustache_Engine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Mustache_Engine的典型用法代码示例。如果您正苦于以下问题:PHP Mustache_Engine类的具体用法?PHP Mustache_Engine怎么用?PHP Mustache_Engine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Mustache_Engine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: renderHTML

 protected function renderHTML()
 {
     $dir = rtrim($this->viewDir);
     $mustache = new \Mustache_Engine(['loader' => new \Mustache_Loader_FilesystemLoader($dir)]);
     $template = $mustache->loadTemplate($this->view);
     return $template->render($this->data);
 }
开发者ID:corvum,项目名称:caw,代码行数:7,代码来源:CawMustache.php


示例2: testLambdasInsidePartialsAreIndentedProperly

    public function testLambdasInsidePartialsAreIndentedProperly()
    {
        $src = <<<EOS
<fieldset>
  {{> input }}
</fieldset>

EOS;
        $partial = <<<EOS
<input placeholder="{{# _t }}Enter your name{{/ _t }}">

EOS;

        $expected = <<<EOS
<fieldset>
  <input placeholder="ENTER YOUR NAME">
</fieldset>

EOS;

        $m = new Mustache_Engine(array(
            'partials' => array('input' => $partial)
        ));

        $tpl = $m->loadTemplate($src);

        $data = new Mustache_Test_Functional_ClassWithLambda();
        $this->assertEquals($expected, $tpl->render($data));
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:29,代码来源:PartialLambdaIndentTest.php


示例3: render

/**
 * render() takes a view name, and a model and renders a mustache template
 *
 * @param $view  string  The view name, which will be used to fetch the actual view
 * @param $model array   An array containing all of the fields that will be passed to mustache for render
 *
 * @return string
 */
function render($view, $model)
{
    $m = new Mustache_Engine(['loader' => new Mustache_Loader_FilesystemLoader(PREFIX . '/views')]);
    $tpl = $m->loadTemplate($view);
    header("Content-Type: text/html; charset=utf-8");
    echo minify_output($tpl->render($model));
}
开发者ID:myklv,项目名称:asana-lite,代码行数:15,代码来源:render.php


示例4: show_news

 public static function show_news($folder = 'posts', $template = 'templates')
 {
     $m = new Mustache_Engine();
     $files = glob("{$folder}/*.md");
     /** /
         usort($files, function($a, $b) {
             return filemtime($a) < filemtime($b);
         });
         /**/
     $html = '';
     foreach ($files as $file) {
         $route = substr($file, strlen($folder) + 1, -3);
         $page = new FrontMatter($file);
         $title = $page->fetch('title') != '' ? $page->fetch('title') : $route;
         $date = $page->fetch('date');
         $author = $page->fetch('author');
         $description = $page->fetch('description') == '' ? '' : $page->fetch('description');
         $data[] = array('title' => $title, 'route' => $route, 'author' => $author, 'description' => $description, 'date' => $date);
     }
     /**/
     function date_compare($a, $b)
     {
         $t1 = strtotime($a['date']);
         $t2 = strtotime($b['date']);
         return $t1 - $t2;
     }
     usort($data, 'date_compare');
     $data = array_reverse($data);
     /**/
     $template = file_get_contents('templates/show_news.tpl');
     $data['files'] = $data;
     return $m->render($template, $data);
     return $html;
 }
开发者ID:modularr,项目名称:markpresslib,代码行数:34,代码来源:MarkPressLib.php


示例5: render

 public function render()
 {
     $m = new \Mustache_Engine();
     $template = $this->template->contents();
     $output = $m->render($template, $this->context);
     $this->output->write($output);
 }
开发者ID:bahulneel,项目名称:php-templatr,代码行数:7,代码来源:Templatr.php


示例6: makeMustache

 /**
  * Compiles plugin's mustache template
  */
 public function makeMustache()
 {
     $dir = __DIR__ . '/views/cache';
     $this->_cleanDir($dir);
     $mustache = new \Mustache_Engine(array('loader' => new \Mustache_Loader_FilesystemLoader(__DIR__ . '/views'), 'cache' => $dir));
     $mustache->loadTemplate('laps');
 }
开发者ID:rarst,项目名称:laps,代码行数:10,代码来源:RoboFile.php


示例7: render

 /**
  * Renders a template using Mustache.php.
  *
  * @see View::render()
  * @param string $template The template name specified in Slim::render()
  * @return string
  */
 public function render($template)
 {
     require_once self::$mustacheDirectory . '/Autoloader.php';
     \Mustache_Autoloader::register(dirname(self::$mustacheDirectory));
     $m = new \Mustache_Engine();
     $contents = file_get_contents($this->getTemplatesDirectory() . '/' . ltrim($template, '/'));
     return $m->render($contents, $this->data);
 }
开发者ID:Alexander173,项目名称:angular-noCaptcha-reCaptcha,代码行数:15,代码来源:Mustache.php


示例8: vimeography_add_mce_popup

 /**
  * Action target that displays the popup to insert a form to a post/page.
  *
  * @access public
  * @return void
  */
 public function vimeography_add_mce_popup()
 {
     $mustache = new Mustache_Engine(array('loader' => new Mustache_Loader_FilesystemLoader(VIMEOGRAPHY_PATH . 'lib/admin/templates')));
     require_once VIMEOGRAPHY_PATH . 'lib/admin/controllers/vimeography/mce.php';
     $view = new Vimeography_MCE();
     $template = $mustache->loadTemplate('vimeography/mce');
     echo $template->render($view);
 }
开发者ID:raulmontejo,项目名称:vimeography,代码行数:14,代码来源:init.php


示例9: getActions

 /**
  * Uma action nesse contexto representa o link que executa uma ação específica
  * em um grid, específicamente na última coluna do grid, na coluna AÇÕES.
  * 
  * @param Mustache_Engine $mustache
  * @param array $row
  */
 public function getActions($mustache, $row)
 {
     $actions = "";
     foreach ($this->actions as $config) {
         $actions .= "  " . HTML::link($mustache->renderHTML($config['url'], $row), '<span class="' . $config['icon_class'] . '"></span> ' . $config['label_text'] . '  ', $config['title'], $config['extra']);
     }
     return $actions;
 }
开发者ID:diego3,项目名称:myframework-core,代码行数:15,代码来源:DefaultTableAction.php


示例10: testCallEatsContext

 public function testCallEatsContext()
 {
     $m = new Mustache_Engine();
     $tpl = $m->loadTemplate('{{# foo }}{{ label }}: {{ name }}{{/ foo }}');
     $foo = new Mustache_Test_Functional_ClassWithCall();
     $foo->name = 'Bob';
     $data = array('label' => 'name', 'foo' => $foo);
     $this->assertEquals('name: Bob', $tpl->render($data));
 }
开发者ID:samplex,项目名称:shorturl,代码行数:9,代码来源:CallTest.php


示例11: mustacheRender

 public static function mustacheRender($template, $values)
 {
     TemplateEngine::getMustacheInstance();
     $m = new Mustache_Engine();
     //
     $response = $m->render($template, $values);
     //        $response = preg_replace('/[\s\t\n\r\s]+/', ' ', $response);
     return $response;
 }
开发者ID:alex2stf,项目名称:phpquick,代码行数:9,代码来源:TemplateEngine.php


示例12: page

 public static function page($arr, $templ_short)
 {
     $mustache = new Mustache_Engine(array('loader' => new Mustache_Loader_FilesystemLoader(dirname(__DIR__) . '/templ/')));
     // Add urls into Arr
     $arr['mainUrl'] = main_url;
     $arr['siteUrl'] = site_url;
     $_templ = $mustache->loadTemplate($templ_short);
     echo $_templ->render($arr);
 }
开发者ID:TheDoxMedia,项目名称:pgs,代码行数:9,代码来源:pg_builder.php


示例13: getMustache

 /**
  * Get a Mustache object.
  *
  * @param   Container  $c  A DI container.
  *
  * @return  \Mustache_Engine
  *
  * @since   2.0
  */
 public function getMustache(Container $c)
 {
     $config = $c->get('config');
     $mustache = new \Mustache_Engine(array('loader' => new \Mustache_Loader_FilesystemLoader($config->get('mustache.views', __DIR__ . '/../templates'), array('extension' => $config->get('mustache.ext', '.md')))));
     $mustache->addHelper('number', array('1f' => function ($value) {
         return sprintf('%.1f', $value);
     }));
     return $mustache;
 }
开发者ID:simonfork,项目名称:tagaliser,代码行数:18,代码来源:MustacheServiceProvider.php


示例14: testStrictCallablesEnabled

 /**
  * @group wip
  * @dataProvider strictCallables
  */
 public function testStrictCallablesEnabled($name, $section, $expected)
 {
     $mustache = new Mustache_Engine(array('strict_callables' => true));
     $tpl = $mustache->loadTemplate('{{# section }}{{ name }}{{/ section }}');
     $data = new StdClass();
     $data->name = $name;
     $data->section = $section;
     $this->assertEquals($expected, $tpl->render($data));
 }
开发者ID:samplex,项目名称:shorturl,代码行数:13,代码来源:StrictCallablesTest.php


示例15: getAddComment

 public function getAddComment()
 {
     $mustache = new \Mustache_Engine(array('loader' => new \Mustache_Loader_FilesystemLoader($this->path_template), 'helpers' => array('i18n' => \Aoloe\Senape\I18n::getInstance($this->settings))));
     $template = $mustache->loadTemplate('comment-form-add');
     // \Aoloe\debug('settings', $this->settings);
     // TODO: translating in the template or here in php before handing over to the template?
     // TODO: pass the current values once and if we have them
     return $template->render(array('has-labels' => false, 'site-current' => $this->settings['senape-site-current'], 'page-current' => $this->settings['senape-page-current'], 'comment-last-id' => null));
 }
开发者ID:aoloe,项目名称:php-senape,代码行数:9,代码来源:Html.php


示例16: renderTemplate

 /**
  * @param $_pageContent : Contenu à "templater"
  * @param null $_data : Source de données optionnelle
  */
 function renderTemplate($_pageContent, $_data = null)
 {
     // Ajout des constantes de chemin absolu
     $_data["PUBLIC_ABSOLUTE_PATH"] = PUBLIC_ABSOLUTE_PATH;
     $_data["SERVER_ABSOLUTE_PATH"] = SERVER_ABSOLUTE_PATH;
     $mustache = new Mustache_Engine();
     // Favicons
     $_data["favicons"] = $mustache->render(file_get_contents("public/html/favicons.html"), $_data);
     echo $mustache->render($_pageContent, $_data);
 }
开发者ID:Swapon444,项目名称:Patrimoine,代码行数:14,代码来源:controller.php


示例17: testCacheLambdaTemplatesOptionWorks

 /**
  * @dataProvider cacheLambdaTemplatesData
  */
 public function testCacheLambdaTemplatesOptionWorks($dirName, $tplPrefix, $enable, $expect)
 {
     $cacheDir = $this->setUpCacheDir($dirName);
     $mustache = new Mustache_Engine(array('template_class_prefix' => $tplPrefix, 'cache' => $cacheDir, 'cache_lambda_templates' => $enable));
     $tpl = $mustache->loadTemplate('{{#wrap}}{{name}}{{/wrap}}');
     $foo = new Mustache_Test_Functional_Foo();
     $foo->wrap = array($foo, 'wrapWithEm');
     $this->assertEquals('<em>' . $foo->name . '</em>', $tpl->render($foo));
     $this->assertCount($expect, glob($cacheDir . '/*.php'));
 }
开发者ID:godofchina,项目名称:myfirstskeleton,代码行数:13,代码来源:HigherOrderSectionsTest.php


示例18: register

 function register()
 {
     if ('POST' == $_SERVER['REQUEST_METHOD']) {
         //stocke les valeurs
         $email = strtolower($_POST["txtMail"]);
         $firstName = $_POST["txtFirstName"];
         $lastName = $_POST["txtLastName"];
         $phone = $_POST["txtPhone"];
         $pass = $_POST["txtPassword"];
         $passCheck = $_POST["txtPasswordConfirm"];
         if (!empty($_POST["txtMail"]) and !empty($_POST["txtFirstName"]) and !empty($_POST["txtLastName"]) and !empty($_POST["txtPhone"]) and !empty($_POST["txtPassword"])) {
             //modifier le numéro de téléphone afin de correspondre à la BD
             $phone = self::normalizePhoneNumber($phone);
             //vérifier si informations valides (email + pass)
             if (Users::getUserIdByName($email) == -1 && $pass == $passCheck) {
                 $salt = self::generateSalt();
                 $crypt = crypt($pass, $salt);
                 $userId = Users::addFamilyOwner($email, $phone, $firstName, $lastName, $crypt, $salt);
                 $owner = $userId;
                 $name = "Contenant principal";
                 $parent = null;
                 $value = 0;
                 $initValue = 0;
                 $warranty = "";
                 $infos = "";
                 $summary = "Contenant de départ";
                 $public = 1;
                 $quantity = 1;
                 Objects::addObject($name, $owner, $parent, $value, $initValue, $warranty, $infos, $summary, $public, $quantity);
                 header(CONNECTION_HEADER . '/registration');
                 if (isset($userId)) {
                     $user = Users::getUser($userId);
                     $headers = 'MIME-Version: 1.0' . "\r\n";
                     $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
                     $to = "";
                     $recipients = Users::getAllAdminMail();
                     foreach ($recipients as $recipient) {
                         $to .= $recipient . ', ';
                     }
                     substr($to, 0, -2);
                     $subject = "Nouvelle demande de patrimoine";
                     $data = array('path' => SERVER_ABSOLUTE_PATH . "/sysadmin", 'user' => $user["UserName"], 'img' => PUBLIC_ABSOLUTE_PATH . "/assets/logo_petit.png");
                     $mustache = new Mustache_Engine();
                     mail($to, $subject, $mustache->render(file_get_contents('public/html/mailtemplateregistration.html'), $data), $headers . "From: " . SENDING_EMAIL);
                 }
             } else {
                 $data = array("SERVER_ABSOLUTE_PATH" => SERVER_ABSOLUTE_PATH, "PUBLIC_ABSOLUTE_PATH" => PUBLIC_ABSOLUTE_PATH, "Error" => true, "ErrorMSG" => Users::getUserIdByName($email) != -1 ? "Adresse courriel déjà en utilisation" : "Vous devez saisir le même mot de passe", "FirstName" => $firstName, "LastName" => $lastName, "Phone" => $phone, "Email" => $email);
                 $this->renderTemplate(file_get_contents(REGISTRATION_PAGE), $data);
             }
         } else {
             $data = array("SERVER_ABSOLUTE_PATH" => SERVER_ABSOLUTE_PATH, "PUBLIC_ABSOLUTE_PATH" => PUBLIC_ABSOLUTE_PATH, "Error" => true, "ErrorMSG" => "Informations manquantes", "FirstName" => $firstName, "LastName" => $lastName, "Phone" => $phone, "Email" => $email);
             $this->renderTemplate(file_get_contents(REGISTRATION_PAGE), $data);
         }
     }
 }
开发者ID:Swapon444,项目名称:Patrimoine,代码行数:55,代码来源:registration.php


示例19: render

 static function render($view, $data)
 {
     global $aplication;
     global $debugbar;
     $app = $aplication->getApp();
     $path = $app->getViews();
     Mustache_Autoloader::register();
     $options = array('extension' => '.mustache');
     $template = new Mustache_Engine(array('loader' => new Mustache_Loader_FilesystemLoader($path, $options)));
     echo $template->render($view, $data);
 }
开发者ID:elephantphp,项目名称:ElephantFreamwork,代码行数:11,代码来源:View.php


示例20: render

 public function render($view)
 {
     if (!is_subclass_of($this, 'Layout')) {
         return;
     }
     $name = $this->name;
     $base = VIEWS_DIR . DIRECTORY_SEPARATOR . 'layout' . DIRECTORY_SEPARATOR . 'mustache';
     $partials = VIEWS_DIR . DIRECTORY_SEPARATOR . 'mustache' . DIRECTORY_SEPARATOR . 'partials';
     $mustache = new Mustache_Engine(array('loader' => new Mustache_Loader_FilesystemLoader($base), 'partials_loader' => new Mustache_Loader_FilesystemLoader($partials)));
     $template = $mustache->loadTemplate($this->name);
     return $template->render($view);
 }
开发者ID:MaitreyaBuddha,项目名称:worklist,代码行数:12,代码来源:Layout.php



注:本文中的Mustache_Engine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP MyCakeTestCase类代码示例发布时间:2022-05-23
下一篇:
PHP Mustache_Autoloader类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap