protected function _renderTemplate($tools)
 {
     $template_file = $this->template_id . '.phtml';
     $path = $tools->locateTemplateByAlias('_mail/' . $template_file);
     $template = new lmbMacroTemplate($path, $tools->getConf('macro'));
     $template->setVars($this->dataset->export());
     return $template->render();
 }
 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();
 }
 function testLocateCompiledTemplate()
 {
     $template_locator = new lmbMacroTemplateLocatorSimple($config = $this->_createMacroConfig());
     $compiled_file_name = lmbMacroTemplate::encodeCacheFileName($this->template_name);
     file_put_contents($config->cache_dir . '/' . $compiled_file_name, 'bar');
     $template = $template_locator->locateCompiledTemplate($this->template_name);
     $this->assertEqual('bar', file_get_contents($template));
 }
 protected function _parseMailTemplate($postfix = '')
 {
     $tools = lmbToolkit::instance();
     $template_file = $this->template_id . $postfix . '.phtml';
     $path = $tools->locateTemplateByAlias('_mail/' . $template_file);
     $template = new lmbMacroTemplate($path, $tools->getConf('macro'));
     $template->setVars($this->dto->export());
     $raw_content = $template->render();
     $parts = explode($this->separator, $raw_content);
     if (1 === count($parts)) {
         throw new lmbException('Subject must be on the top of mail template separated by "' . $this->separator . '"');
     }
     $this->subject = $parts[0];
     $this->text_content = $parts[1];
     if (3 === count($parts)) {
         $this->html_content = $parts[2];
     } else {
         $this->html_content = $this->text_content;
     }
 }
Beispiel #5
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();
}
 function locateCompiledTemplate($file_name)
 {
     return $this->config->cache_dir . '/' . lmbMacroTemplate::encodeCacheFileName($file_name);
 }
Beispiel #7
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++) {