Esempio n. 1
0
 public function __construct($config = array())
 {
     $_vars = new \ArrayObject(array(), \ArrayObject::ARRAY_AS_PROPS);
     if (!isset($config) && file_exists(ROOT_PATH . '/config/templates.xml')) {
         //获取系统变量
         $_sxe = simplexml_load_file(ROOT_PATH . '/config/templates.xml');
         $_tags = $_sxe->xpath('/root/taglib');
         foreach ($_tags as $_tag) {
             $this->_config["{$_tag->name}"] = $_tag->value;
         }
     } else {
         //$this->_config = $config;
         $this->_config = $config + $this->_config;
     }
     if (empty(self::$modifiers)) {
         $this->init_modifier();
     }
     if (empty(self::$extends)) {
         ViewTemplate::helper('elapsed_time', function () {
             return mstimer(1);
         });
         self::extend(function ($content) {
             return ViewTemplate::parse($content);
         });
     }
 }
Esempio n. 2
0
<?php

define('FADDLE_PATH', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'src');
require FADDLE_PATH . '/Faddle/autoload.php';
$config = array('default' => array('suffix' => '.view.php', 'template_path' => dirname(__FILE__) . '/templates', 'storage_path' => 'cache', 'bucket' => 'templates', 'engine' => 'default', 'cache' => true, 'cache_path' => 'cache', 'expire' => 5000), 'nature' => array('suffix' => '.php', 'template_path' => dirname(__FILE__) . '/templates', 'storage_path' => 'cache', 'bucket' => 'templates', 'engine' => false, 'expire' => 0));
$args = array('engine' => 'Faddle', 'foo' => 'fooooo', 'bar' => 'baaaaar', 'user' => array('name' => 'seo', 'role' => 'm'), 'users' => array('Name_1', 'Name_2'));
mstimer();
$view = new Faddle\View($config);
$content = $view->show('hello', $args);
ob_start() and ob_clean();
echo $content;
ob_end_flush();