当前位置: 首页>>代码示例>>PHP>>正文


PHP Mustache_Engine类代码示例

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


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


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