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


PHP Mustache_Engine::loadTemplate方法代码示例

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


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

示例1: loadTemplate

 /**
  * Seleciona qual render do mustache deverá ser chamado
  * E retorna o template para o arquivo solicitado
  * 
  * @param string $filename Nome do arquivo que deverá ser carregado. O arquivo deve existir em PATH_APP . '/view/' . $filename . '.mustache'
  * @return \Mustache_Template
  */
 protected function loadTemplate($filename)
 {
     if (file_exists(PATH_APP . '/view/' . $filename . '.mustache')) {
         return $this->mustacheapp->loadTemplate($filename);
     } else {
         return $this->mustache->loadTemplate($filename);
     }
 }
开发者ID:diego3,项目名称:myframework-core,代码行数:15,代码来源:Template.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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: generateBlog

 public function generateBlog()
 {
     set_time_limit(0);
     global $app;
     $this->parser = new \Parsedown();
     $data = $this->getData();
     $layout = $data['settings']['layout'] ?: 'default';
     $layoutDir = $app->view->getData('layoutsDir') . $layout . '/';
     // first copy all contents of template to public folder
     copy_directory($layoutDir, $this->publicDir);
     // now create actual html pages
     $mustache = new \Mustache_Engine(array('loader' => new \Mustache_Loader_FilesystemLoader($layoutDir), 'partials_loader' => new \Mustache_Loader_FilesystemLoader($layoutDir . '/partials')));
     $mustacheFiles = glob($layoutDir . '/*.mustache');
     $excludedFiles = array('category', 'post', 'page', 'archive', 'tag');
     foreach ($mustacheFiles as $mustacheFile) {
         $fileName = basename($mustacheFile);
         $fileName = str_replace('.mustache', '', $fileName);
         // we will generate these later
         if (true === in_array($fileName, $excludedFiles)) {
             continue;
         }
         $template = $mustache->loadTemplate($fileName);
         $html = $template->render($data);
         file_put_contents($this->publicDir . $fileName . '.html', $html);
     }
     // delete mustache particals folders from public folder
     rrmdir($this->publicDir . 'partials/');
     // delete *.mustache from public dir
     $mustacheFiles = glob($this->publicDir . '/*.mustache');
     foreach ($mustacheFiles as $mustacheFile) {
         @unlink($mustacheFile);
     }
     // generate post files
     $this->generatePostPageFiles($mustache, $data, 'post');
     // generate page files
     $this->generatePostPageFiles($mustache, $data, 'page');
     // generate category and tag files
     $this->generateCategoryTagFiles($mustache, $data, 'category');
     $this->generateCategoryTagFiles($mustache, $data, 'tag');
     // generate archive files
     $this->generateArchiveFiles($mustache, $data);
     // generate RSS file
     $this->generateRSS($data);
     // generate sitemap.xml
     $this->generateSitemap($data);
     // copy blog data file
     copy('data/blog.json', 'public/data/blog.json');
     $message = '';
     $message .= 'Blog has been generated in <strong>public</strong> folder :)<br><br>';
     $message .= '<a id="viewGenLog" class="btn btn-primary">View Log</a><br><br>';
     $message .= '<div id="genlog">' . $this->getGenerateLog($this->generateLog) . '</div>';
     echo $message;
 }
开发者ID:sarfraznawaz2005,项目名称:bloggercms,代码行数:53,代码来源:Generator.php

示例14: capture

 protected static function capture($kohana_view_filename, array $kohana_view_data)
 {
     $extension = func_get_args()[2];
     // is mustache ?
     // If it's not a mustache file, do the default:
     if ($extension == 'php') {
         return Kohana_View::capture($kohana_view_filename, $kohana_view_data);
     }
     // continue
     $vars = Arr::merge(self::kohanaVariables(), View::$_global_data);
     $vars = Arr::merge($vars, $kohana_view_data);
     $conf = Kohana::$config->load('mustache')->as_array();
     $mustache = new Mustache_Engine($conf);
     $tpl = $mustache->loadTemplate($kohana_view_filename);
     return $tpl->render($vars);
 }
开发者ID:timophey,项目名称:kohana-mustache,代码行数:16,代码来源:Mustache.php

示例15: mustache

function mustache($viewPath, $values = [])
{
    global $controller;
    global $renderArgs;
    global $strings;
    $mustache = new Mustache_Engine(['loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__) . '/views'), 'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__) . '/views/partials'), 'strict_callables' => true]);
    $tpl = $mustache->loadTemplate($viewPath);
    $values["controller:{$controller}?"] = true;
    $values["controller"] = $controller;
    foreach (["firstName", "lastName", "roles", "id", "email"] as $i) {
        if (isset($_SESSION[$i])) {
            $values["currentUser:{$i}"] = $_SESSION[$i];
        }
    }
    if (isset($_SESSION["id"])) {
        $reports = reports("SELECT SUM(hours) FROM logs WHERE created_by = :created_by AND date >= :start AND date <= :end", $_SESSION["id"], ":created_by", ":start", ":end");
        foreach (["weekly", "monthly", "quarterly", "annually"] as $j) {
            $values["currentUser:{$j}"] = $reports[$j];
        }
        $thisWeek = query("SELECT SUM(hours) FROM logs WHERE created_by = :created_by AND date >= :start AND date <= :end", [":created_by" => $_SESSION["id"], ":start" => date("Y-m-d", strtotime("last Sunday")), ":end" => date("Y-m-d", strtotime("this Saturday"))])[0][0];
        if ($thisWeek === null) {
            $thisWeek = 0;
        }
        $values["currentUser:thisWeek"] = $thisWeek;
    }
    # Roles identifier for template
    foreach (roles() as $role) {
        $values["currentUser:{$role}?"] = true;
    }
    foreach ($renderArgs as $key => $value) {
        if (isset($strings[$value])) {
            $value = $strings[$value];
        }
        $values["args:{$key}"] = $value;
    }
    return $tpl->render($values);
}
开发者ID:panbowen,项目名称:tasklog,代码行数:37,代码来源:index.php


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