protected function templateToEach(Token $token) { $children = $token->getChildren(); $has_items = false; foreach ($children as $child) { if ($child->name == 'item') { $has_items = true; break; } } if (!$has_items) { return; } $with_each_token = new Token('with_each', 'double', array('select' => '$.items')); $with_each_token->setChildren($children); $token->clearChildren(); $token->addChild($with_each_token); }
protected function childrenToCode(Token $token) { $parts = array(); $param_parts = array(); foreach ($token->getChildren() as $child) { if ($child->name === 'param') { $param_parts[] = $this->tokenParamToCode($child); } elseif ($child->name !== 'elseif' && $child->name !== 'else') { $parts[] = $this->getTokenCode($child, $token); } } if (count($parts) == 0) { return ''; } $code = '?>' . join("", $param_parts) . join("", $parts) . "<?php "; return $code; }