/** * Invokes filter. * @param string * @return string */ public function __invoke($s) { $this->parser->context = Parser::CONTEXT_TEXT; $this->parser->escape = 'Nette\\Templating\\DefaultHelpers::escapeHtml|'; $this->parser->setDelimiters('\\{(?![\\s\'"{}*])', '\\}'); return $this->parser->parse($s); }
/** * {syntax ...} */ public function macroSyntax($var) { switch ($var) { case '': case 'latte': $this->parser->setDelimiters('\\{(?![\\s\'"{}])', '\\}'); // {...} break; case 'double': $this->parser->setDelimiters('\\{\\{(?![\\s\'"{}])', '\\}\\}'); // {{...}} break; case 'asp': $this->parser->setDelimiters('<%\\s*', '\\s*%>'); /* <%...%> */ break; case 'python': $this->parser->setDelimiters('\\{[{%]\\s*', '\\s*[%}]\\}'); // {% ... %} | {{ ... }} break; case 'off': $this->parser->setDelimiters('[^\\x00-\\xFF]', ''); break; default: throw new ParseException("Unknown syntax '{$var}'", 0, $this->parser->line); } }
/** * Invokes filter. * * @param string * * @return string */ public function __invoke($s) { return $this->compiler->compile($this->parser->parse($s)); }
/** * Compilation time templating filters * * @param Nette\Templating\Template * @return void */ public final function templatePrepareFilters($template) { // We cannot use Nette\Latte\Engine class directly, because we need our SystemMacros // to be declared befor UIMacros // $this->getPresenter()->getContext()->nette->createLatte() $parser = new Nette\Latte\Parser(); $compiler = new Nette\Latte\Compiler(); $compiler->defaultContentType = Nette\Latte\Compiler::CONTENT_XHTML; $this->lattePrepareMacros($compiler, $template); $template->registerFilter(function ($s) use($compiler, $parser) { return $compiler->compile($parser->parse($s)); }); }
/** * Invokes filter. * @param string * @return string */ public function __invoke($s) { $this->parser->context = array(Parser::CONTEXT_TEXT); $this->parser->setDelimiters('\\{(?![\\s\'"{}])', '\\}'); return $this->parser->parse($s); }
public function addMacro($name, $begin, $end = NULL) { $this->macros[$name] = array($begin, $end); $this->parser->addMacro($name, $this); }