/** * Parse action {action ...} or {action(...) ...} * * @static * @param Tokenizer $tokens * @throws \LogicException * @throws \RuntimeException * @throws Error\TokenizeException * @return string */ public function parseAct(Tokenizer $tokens) { $action = $tokens->get(Tokenizer::MACRO_STRING); $tokens->next(); if ($tokens->is("(", T_DOUBLE_COLON, T_NS_SEPARATOR) && !$tokens->isWhiteSpaced()) { // just invoke function or static method $tokens->back(); return $this->out($this->parseExpr($tokens)); } elseif ($tokens->is('.')) { $name = $tokens->skip()->get(Tokenizer::MACRO_STRING); if ($action !== "macro") { $name = $action . "." . $name; } return $this->parseMacroCall($tokens, $name); } if ($info = $this->_fenom->getTag($action, $this)) { $tag = new Tag($action, $this, $info, $this->_body); if ($tokens->is(':')) { // parse tag options do { $tag->tagOption($tokens->next()->need(T_STRING)->getAndNext()); } while ($tokens->is(':')); } $code = $tag->start($tokens); if ($tag->isClosed()) { $tag->restoreAll(); } else { array_push($this->_stack, $tag); } return $code; } for ($j = $i = count($this->_stack) - 1; $i >= 0; $i--) { // call function's internal tag if ($this->_stack[$i]->hasTag($action, $j - $i)) { return $this->_stack[$i]->tag($action, $tokens); } } if ($tags = $this->_fenom->getTagOwners($action)) { // unknown template tag throw new TokenizeException("Unexpected tag '{$action}' (this tag can be used with '" . implode("', '", $tags) . "')"); } else { throw new TokenizeException("Unexpected tag '{$action}'"); } }
/** * @param Tokenizer $tokens * @param Tag $tag */ public static function stripOpen(Tokenizer $tokens, Tag $tag) { $expected = $tokens->get(T_STRING) == "true" ? true : false; $tokens->next(); $tag->setOption(\Fenom::AUTO_STRIP, $expected); }