function wrapTemplate($file, $slots_handlers)
 {
     $template = new lmbMacroTemplate($file, $this->__config);
     $template->setVars(get_object_vars($this));
     //global template vars
     foreach ($slots_handlers as $name => $handlers) {
         $template->set('__slot_handlers_' . $name, $handlers);
     }
     $template->setChildExecutor($this);
     //from now we consider the wrapper to be a master variable context
     echo $template->render();
 }
Exemple #2
0
$file = $argv[1];
$forcecompile = false;
if (isset($argv[2])) {
    $forcecompile = (bool) $argv[2];
}
$forcescan = false;
if (isset($argv[3])) {
    $forcescan = (bool) $argv[3];
}
set_include_path(dirname(__FILE__) . '/../../../../');
require_once 'limb/core/common.inc.php';
require_once 'limb/core/src/lmbSet.class.php';
require_once 'limb/macro/src/lmbMacroTemplate.class.php';
require_once dirname(__FILE__) . '/profile.inc.php';
$tpl = new lmbMacroTemplate($file, array('cache_dir' => '/tmp/macro', 'forcecompile' => $forcecompile, 'forcescan' => $forcescan, 'tpl_scan_dirs' => array(dirname(__FILE__))));
/*$tpl = new lmbMacroTemplate($file, new lmbSet(array('cache_dir' => '/tmp/macro', 
  'forcecompile' => $forcecompile, 
  'forcescan' => $forcescan, 
  'tpl_scan_dirs' => array(dirname(__FILE__)))));*/
for ($i = 2; $i < $argc; $i++) {
    if (strpos($argv[$i], '=') === false) {
        continue;
    }
    list($key, $value) = explode('=', $argv[$i]);
    $tpl->set($key, $value);
}
profile_start();
for ($i = 0; $i < 1000; $i++) {
    $tpl->render();
}
profile_end("running {$i} iterations of render");
Exemple #3
0
<?php

set_include_path(dirname(__FILE__) . '/../../../../');
define('WACT_CACHE_DIR', '/tmp/wact');
define('WACT_TPLS', dirname(__FILE__) . '/tpl');
require_once 'limb/core/common.inc.php';
require_once 'limb/macro/src/lmbMacroTemplate.class.php';
require_once 'limb/wact/common.inc.php';
require_once 'limb/wact/src/WactTemplate.class.php';
require_once 'limb/wact/src/WactDefaultTemplateConfig.class.php';
for ($i = 0; $i < 1000; $i++) {
    $j = $i;
}
$name = 'Bob';
$tpl = new lmbMacroTemplate('macro.phtml', array('cache_dir' => '/tmp/macro', 'forcecompile' => false, 'forcescan' => false, 'tpl_scan_dirs' => array(dirname(__FILE__) . '/tpl')));
$tpl->set('name', $name);
$mark = microtime(true);
$tpl->render();
echo "MACRO 1xrender: " . (microtime(true) - $mark) . "\n";
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {
    $tpl->render();
}
echo "MACRO 1000xrender: " . (microtime(true) - $mark) . "\n";
$tpl = new WactTemplate('wact.html', new WactDefaultTemplateConfig(dirname(__FILE__) . '/settings/wact.ini'));
$tpl->set('name', $name);
$mark = microtime(true);
$tpl->capture();
echo "WACT 1xrender: " . (microtime(true) - $mark) . "\n";
$mark = microtime(true);
for ($i = 0; $i < 1000; $i++) {