Bolt\Twig\SwitchNode::compile PHP Метод

compile() публичный Метод

public compile ( Twig_Compiler $compiler )
$compiler Twig_Compiler
    public function compile(\Twig_Compiler $compiler)
    {
        $compiler->addDebugInfo($this);
        $compiler->write('switch (')->subcompile($this->getNode('value'))->raw(") {\n")->indent();
        for ($i = 0; $i < count($this->getNode('cases')); $i += 2) {
            $compiler->write('case ')->subcompile($this->getNode('cases')->getNode($i))->raw(":\n")->indent()->subcompile($this->getNode('cases')->getNode($i + 1))->write('')->raw("break;\n");
        }
        if ($this->hasNode('default') && null !== $this->getNode('default')) {
            $compiler->write("default:\n")->indent()->subcompile($this->getNode('default'))->write('')->raw("break;\n");
        }
        $compiler->outdent()->write("}\n");
    }