當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tpl::configure方法代碼示例

本文整理匯總了PHP中Tpl::configure方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tpl::configure方法的具體用法?PHP Tpl::configure怎麽用?PHP Tpl::configure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tpl的用法示例。


在下文中一共展示了Tpl::configure方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getContent

 /**
  * Outputs the content by finding the correct template
  * and view file, if needed.
  */
 public function getContent()
 {
     $tplDir = $this->isView ? $this->view->tpl : Config::$template;
     $config = array('base_url' => null, 'tpl_dir' => array(APP . 'template/' . $tplDir . '/'), 'cache_dir' => APP . 'tmp/', 'debug' => true, 'php_enabled' => true, 'tpl_ext' => 'php');
     Tpl::configure($config);
     $tpl = new Tpl();
     $tpl->assign('isView', $this->isView);
     $tpl->assign('title', Config::$data->title);
     if ($this->isView) {
         $vars = $this->view->getVars();
         if (!empty($vars)) {
             foreach ($vars as $key => $value) {
                 $tpl->assign($key, $value);
             }
         }
         $sep = DIRECTORY_SEPARATOR;
         $view = '..' . $sep . '..' . $sep . APP . 'view/' . $this->view->path;
     } else {
         $view = $this->view;
         if ($this->isJson === true) {
             echo $view;
             exit;
         }
     }
     try {
         File::get(APP . 'template/' . $tplDir . '/template.php');
         if (class_exists('Template\\Model\\Template')) {
             $tpl_class = new Template\Model\Template();
             $tpl->assign('template', $tpl_class);
         }
     } catch (Exception $e) {
     }
     $tpl->assign('view', $view);
     $tpl->draw('index');
 }
開發者ID:fluorine-framework,項目名稱:framework,代碼行數:39,代碼來源:bootstrap.php

示例2: fixPath

<?php

namespace Rain;

require_once "Tpl.php";
function fixPath(&$path)
{
    $path = preg_replace(array("#(/{2,})#", "#(/\\./+)#"), array("/", "/"), $path);
    $path = str_replace("/", "\\", $path);
}
$tpl = new Tpl();
$tpl->configure(array("tpl_dir" => "../templates/"));
$fs = $tpl->countTemplates();
$grid = (new Db())->countTemplates();
echo "Count templates filesystem: " . $fs['count'] . "<br />";
echo "Count templates in cache: " . $grid['count'] . "<br /><br />";
array_walk($fs['names'], 'Rain\\fixPath');
array_walk($grid['names'], 'Rain\\fixPath');
if ($fs['count'] != $grid['count']) {
    echo "Not ready for production yet!<br />";
    echo "Missing templates in cache:<br />";
    foreach ($fs['names'] as $f) {
        if (!in_array($f, $grid['names'])) {
            echo $f . "<br />";
        }
    }
} else {
    echo "Ready for production!";
}
#echo "<br />";
#print_r($fs['names']);
開發者ID:bozhinov,項目名稱:Mod_mongodb-for-RainTpl3,代碼行數:31,代碼來源:Test-Production-Ready.php


注:本文中的Tpl::configure方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。