/** * Handler for unknown tags, handle else tags * * @param string $tag * @param array $params * @param array $tokens */ public function unknownTag($tag, $params, &$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 array $params * @param array $tokens */ public function unknownTag($tag, $params, &$tokens) { $whenSyntaxRegexp = new LiquidRegexp('/' . LIQUID_QUOTED_FRAGMENT . '/'); switch ($tag) { case 'when': // push the current nodelist onto the stack and prepare for a new one if ($whenSyntaxRegexp->match($params)) { $this->push_nodelist(); $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->push_nodelist(); $this->right = null; $this->elseNodelist =& $this->_nodelist; $this->_nodelist = array(); break; default: parent::unknownTag($tag, $params, $tokens); } }