Parses the Twig stream and creates a Twig_Node_Include instance that includes
the View's template.

@return Twig_Node_Include
433883
public function parse(Twig_Token $token)
    {
        $parser = $this->parser;
        $stream = $parser->getStream();

        $view = $parser->getExpressionParser()->parseExpression();

        $variablesOverride = new Twig_Node_Expression_Array(array(), $token->getLine());
        if ($stream->test(Twig_Token::NAME_TYPE, 'with')) {
            $stream->next();

            $variablesOverride->addElement($this->parser->getExpressionParser()->parseExpression());
        }

        $stream->expect(Twig_Token::BLOCK_END_TYPE);

        $viewTemplateExpr = new Twig_Node_Expression_MethodCall(
            $view,
            'getTemplateFile',
            new Twig_Node_Expression_Array(array(), $token->getLine()),
            $token->getLine()
        );

        $variablesExpr = new Twig_Node_Expression_MethodCall(
            $view,
            'getTemplateVars',
            $variablesOverride,
            $token->getLine()
        );

        return new Twig_Node_Include(
            $viewTemplateExpr,
            $variablesExpr,
            $only = false,
            $ignoreMissing = false,
            $token->getLine()
        );
    }
874630
protected function parse()
	{
		if (($s = $this->copy_until_char('<'))==='')
		{
			return $this->read_tag();
		}

		// text
		$node = new Node($this);
		++$this->cursor;
		$node->_[self::HDOM_INFO_TEXT] = $s;
		$this->link_nodes($node, false);
		return true;
	}
1176598
public function getTwig()
    {
        if (!$this->twig) {
            Twig_Autoloader::register();
            $this->twig_loader = new Twig_Loader_Filesystem($this->base_view_path);

            $this->twig = new Twig_Environment(
                $this->twig_loader,
                $this->loader_configs
            );
        }

        return $this->twig;
    }
1027372
function render() {
        //\Debug::info(TplVar::instance()->vars());
        //\Debug::info($this->layout);
        return Twig::from_template($this->layout)
                        ->set(Page_TplVar::instance()->vars())
                        ->render();
    }
651709
public function template_include( $template ) {

		if ( '.twig' === substr( $template, - 5 ) ) {
			/** @var \Twig_Environment $twig */
			$twig = $this['twig.environment'];

			echo $twig->render( basename( $template ), apply_filters( 'meadow_context', array() ) );

			die();
		}

		return $template;
	}
207583
public function parse( Twig_Token $token ) {

		$nodes  = array();
		$parser = $this->parser;
		$stream = $parser->getStream();

		$stream->expect( Twig_Token::BLOCK_END_TYPE );
		$nodes['callback'] = $parser->subparse( array( $this, 'decide_comments_end' ), true );
		$stream->expect( Twig_Token::BLOCK_END_TYPE );

		return new Comments_Node( $nodes, array(), $token->getLine(), $this->getTag() );
	}
1005036
protected function registerTwigParser()
    {
        /*
         * Register system Twig environment
         */
        App::singleton('twig.environment', function ($app) {
            $twig = new Twig_Environment(new TwigLoader, ['auto_reload' => true]);
            $twig->addExtension(new TwigExtension);
            return $twig;
        });

        /*
         * Register .htm extension for Twig views
         */
        App::make('view')->addExtension('htm', 'twig', function () {
            return new TwigEngine(App::make('twig.environment'));
        });
    }
1358128
public static function parser()
	{
		if ( ! empty(static::$_parser))
		{
			static::$_parser->setLoader(static::$_parser_loader);
			return static::$_parser;
		}

		// Twig Environment
		$twig_env_conf = \Config::get('parser.View_Twig.environment', array('optimizer' => -1));
		static::$_parser = new Twig_Environment(static::$_parser_loader, $twig_env_conf);

		foreach (\Config::get('parser.View_Twig.extensions') as $ext)
		{
			static::$_parser->addExtension(new $ext());
		}

		// Twig Lexer
		static::$_twig_lexer_conf = \Config::get('parser.View_Twig.delimiters', null);
		if (isset(static::$_twig_lexer_conf))
		{
			isset(static::$_twig_lexer_conf['tag_block'])
				and static::$_twig_lexer_conf['tag_block'] = array_values(static::$_twig_lexer_conf['tag_block']);
			isset(static::$_twig_lexer_conf['tag_comment'])
				and static::$_twig_lexer_conf['tag_comment'] = array_values(static::$_twig_lexer_conf['tag_comment']);
			isset(static::$_twig_lexer_conf['tag_variable'])
				and static::$_twig_lexer_conf['tag_variable'] = array_values(static::$_twig_lexer_conf['tag_variable']);
		}

		return static::$_parser;
	}
376883
public function parse()
    {
        $path = $this->_contents;

        if (!isset($this->_parsed_data[$path])) {
            $context = $this->getCommandContext();
            $context->data = $path;
            $this->getCommandChain()->run(LibBaseTemplateFilter::MODE_READ, $context);
            $this->_parsed_data[$path] = $context->data;
        }

        return $this->_parsed_data[$path];
    }
582905
public function parse(Twig_Token $token)
    {
        $stream = $this->parser->getStream();
        $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
        $body = null;
        $params = [];

        if ($stream->test(Twig_Token::NAME_TYPE, 'default')) {
            $stream->next();
            $params = $this->loadParams($stream);

            $body = $this->parser->subparse([$this, 'decidePlaceholderEnd'], true);
            $stream->expect(Twig_Token::BLOCK_END_TYPE);
        }
        else {
            $params = $this->loadParams($stream);
        }

        return new PlaceholderNode($name, $params, $body, $token->getLine(), $this->getTag());
    }
88125
public function parse()
	{
		$strBuffer = parent::parse();

		if (TL_MODE == 'BE')
		{
			$strBuffer = '<div class="tl_ce ' . $this->strTemplate . '">' . $strBuffer . '</div>';
		}
		
		return $strBuffer;
	}
809229
public function render()
    {
        $this->setViewFullPath($this->getFileFullPath());
        $this->setTemplateFullPath($this->getFileFullPath('template'));

        if (file_exists($this->getViewFullPath())) {
            ob_start();
            include $this->getViewFullPath();
            $this->setContent(ob_get_contents());
            ob_end_clean();
        } else {
            MbException::registerError(new \Exception("The file {$this->getViewFullPath()} not found!"));
        }

        if (file_exists($this->getTemplateFullPath())) {
            ob_start();
            include $this->getTemplateFullPath();
            $this->setContent(ob_get_contents());
            ob_end_clean();
        } else {
            MbException::registerError(new \Exception("The file {$this->getTemplateFullPath()} not found!"));
        }

        return $this->getContent();
    }
1109304
protected function parseDocument()
    {
        $start = $this->token->getStart();
        $definitions = [];

        do {
            if ($this->peek(Token::BRACE_L_TYPE)) {
                $definitions[] = $this->parseOperationDefinition();
            } else if ($this->peek(Token::NAME_TYPE)) {
                $value = $this->token->getValue();
                if ($value === 'query' || $value === 'mutation') {
                    $definitions[] = $this->parseOperationDefinition();
                } else if ($value === 'fragment') {
                    $definitions[] = $this->parseFragmentDefinition();
                } else {
                    throw $this->unexpected();
                }
            } else {
                throw $this->unexpected();
            }
        } while (!$this->skip(Token::EOF_TYPE));

        return new Document($definitions, $this->location($start));
    }
325958
protected function parseMarkOption(\Twig_Token $token, \Twig_TokenStream $stream)
    {
        $this->testToken('mark', $token, $stream);

        $markValue = $this->getNextExpectedStringValueFromStream($stream, \Twig_Token::NUMBER_TYPE);

        while ($stream->test(\Twig_Token::OPERATOR_TYPE)
            || $stream->test(\Twig_Token::PUNCTUATION_TYPE)
            || $stream->test(\Twig_Token::NUMBER_TYPE)
        ) {
            $markValue .= $stream->getCurrent()->getValue();
            $stream->next();
        }

        return $markValue;
    }
63894
protected function parseCodeBlock()
    {
        $stream = $this->parser->getStream();

        while (!$stream->getCurrent()->test(\Twig_Token::BLOCK_END_TYPE)) {
            $this->parseEncounteredToken($stream->getCurrent(), $stream);
        }

        $stream->expect(\Twig_Token::BLOCK_END_TYPE);
        $this->body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
        $stream->expect(\Twig_Token::BLOCK_END_TYPE);
    }
343872
public function parse(\Twig_Token $token)
    {
        list($type, $options, $variables, $skip, $loop) = $this->parseArguments();

        $stream = $this->parser->getStream();
        $lineno = $stream->getCurrent()->getLine();

        $superblock = new Superblock($type, $options, $loop, $lineno, $this->getTag());
        $name = $superblock->getAttribute('name');
        $reference = new SuperblockReference($name, $variables, $loop, $lineno, $this->getTag());
        $reference->setAttribute('parent_name', $name);

        $this->parser->setBlock($name, $superblock);
        $this->parser->pushLocalScope();
        $this->parser->pushBlockStack($name);

        if ($skip) {
            $this->parser->popBlockStack();
            $this->parser->popLocalScope();

            return $reference;
        }

        // body content
        $sBlocks = new \Twig_Node([], [], $lineno);
        $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
        $previousTwigNode = null;

        if (0 === \count($body) || null !== $body->getNodeTag()) {
            $body = new \Twig_Node([$body], [], $lineno);
        }

        if (null === $body->getNodeTag()) {
            /* @var \Twig_Node $node */
            foreach ($body->getIterator() as $node) {
                if (!$node instanceof \Twig_Node) {
                    continue;
                }

                if ($node instanceof SuperblockReference) {
                    $this->pushClosureNode($sBlocks, $variables, $name, $previousTwigNode);
                    $previousTwigNode = null;

                    $node->setAttribute('is_root', false);
                    $node->setAttribute('parent_name', $name);
                    $sBlocks->setNode(\count($sBlocks), $node);
                } elseif ($node instanceof \Twig_Node_Set) {
                    $this->pushClosureNode($sBlocks, $variables, $name, $previousTwigNode);
                    $previousTwigNode = null;

                    $sBlocks->setNode(\count($sBlocks), $node);
                } elseif (!$node instanceof \Twig_Node_Text || ($node instanceof \Twig_Node_Text && '' !== trim($node->getAttribute('data')))) {
                    if (null === $previousTwigNode) {
                        $previousTwigNode = new SuperblockClosure(new \Twig_Node([], [], $lineno), $node->getTemplateLine());
                    }

                    $previousTwigNode->getNode('body')->setNode(\count($previousTwigNode->getNode('body')), $node);
                }
            }
        }

        $this->pushClosureNode($sBlocks, $variables, $name, $previousTwigNode);

        $superblock->setNode('sblocks', $sBlocks);

        $stream->expect(\Twig_Token::BLOCK_END_TYPE);

        $this->parser->popBlockStack();
        $this->parser->popLocalScope();

        return $reference;
    }
525477
protected function getTwig()
    {
        if (null === $this->twig) {
            $this->twig = new \Twig_Environment(new \Twig_Loader_Filesystem(self::TEMPLATE_DIR), [
                'debug'            => true,
                'cache'            => false,
                'strict_variables' => true,
                'autoescape'       => false,
            ]);

            $this->twig->addExtension(new StringExtension());

            $class = sprintf(
                '\Gdbots\Pbjc\Generator\Twig\%sGeneratorExtension',
                StringUtils::toCamelFromSlug(static::LANGUAGE)
            );

            $this->twig->addExtension(new $class($this->compileOptions, $this));
        }

        return $this->twig;
    }