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(); }
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; } }
$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");