/** * Handler for unknown tags, handle else tags * * @param string $tag * @param array $params * @param array $tokens */ public function unknownTag($tag, $params, array $tokens) { if ($tag == 'else' || $tag == 'elsif') { // Update reference to nodelistHolder for this block $this->nodelist =& $this->nodelistHolders[count($this->blocks) + 1]; $this->nodelistHolders[count($this->blocks) + 1] = array(); array_push($this->blocks, array($tag, $params, &$this->nodelist)); } else { parent::unknownTag($tag, $params, $tokens); } }
/** * Unknown tag handler * * @param string $tag * @param string $params * @param array $tokens * * @throws \Liquid\LiquidException */ public function unknownTag($tag, $params, array $tokens) { $whenSyntaxRegexp = new Regexp('/' . Liquid::get('QUOTED_FRAGMENT') . '/'); switch ($tag) { case 'when': // push the current nodelist onto the stack and prepare for a new one if ($whenSyntaxRegexp->match($params)) { $this->pushNodelist(); $this->right = $whenSyntaxRegexp->matches[0]; $this->nodelist = array(); } else { throw new LiquidException("Syntax Error in tag 'case' - Valid when condition: when [condition]"); // harry } break; case 'else': // push the last nodelist onto the stack and prepare to recieve the else nodes $this->pushNodelist(); $this->right = null; $this->elseNodelist =& $this->nodelist; $this->nodelist = array(); break; default: parent::unknownTag($tag, $params, $tokens); } }