public function compile($input, $path = null)
    {

        //Compiler reset
        $this->files = $path ? [$path] : [];
        $this->mixins = [];
        $this->calledMixins = [];
        $this->blocks = [];
        $this->level = 0;
        $this->iteratorId = 0;
        $this->forceInline = false;

        //Parse the input into an AST
        $node = null;
        try {

            $node = $this->parser->parse($input);
        } catch(\Exception $e) {

            //This is needed to be able to keep track of the
            //file path that is erroring
            if (!($e instanceof Exception))
                $this->throwException($e->getMessage());
            else throw $e;
        }

        //There are some things we need to take care of before compilation
        $this->handleImports($node);
        $this->handleBlocks($node);
        $this->handleMixins($node);

        //The actual compilation process ($node is the very root \Tale\Pug\Parser\Node of everything)
        $phtml = $this->compileNode($node);


        //Reset the level again for our next operations
        $this->level = 0;
        //Now we append/prepend specific stuff (like mixin functions and helpers)
        $mixins = $this->compileMixins();

        $helpers = '';
        if ($this->options['stand_alone']) {

            $helpers = file_get_contents(__DIR__.'/Compiler/functions.php')."\n?>\n";
            $helpers .= $this->createCode('namespace {');
        }

        //Put everything together
        $phtml = implode('', [$helpers, $mixins, $phtml]);

        if ($this->options['stand_alone'])
            $phtml .= $this->createCode('}');

        //Reset the files after compilation so that compileFile may resolve correctly
        //Happens when you call compileFile twice on different files
        //Note that Compiler only uses the include-path, when there is no file in the
        //file name storage $_files
        $this->files = [];

        //Return the compiled PHTML
        return trim($phtml);
    }
public function compile($input, $path = null)
    {

        //Compiler reset
        $this->files = $path ? [$path] : [];
        $this->mixins = [];
        $this->calledMixins = [];
        $this->blocks = [];
        $this->level = 0;
        $this->iteratorId = 0;
        $this->forceInline = false;

        //Parse the input into an AST
        $node = null;
        try {

            $node = $this->parser->parse($input);
        } catch(\Exception $e) {

            //This is needed to be able to keep track of the
            //file path that is erroring
            if (!($e instanceof Exception))
                $this->throwException($e->getMessage());
            else throw $e;
        }

        //There are some things we need to take care of before compilation
        $this->handleImports($node);
        $this->handleBlocks($node);
        $this->handleMixins($node);

        //The actual compilation process ($node is the very root \Tale\Pug\Parser\Node of everything)
        $phtml = $this->compileNode($node);


        //Reset the level again for our next operations
        $this->level = 0;
        //Now we append/prepend specific stuff (like mixin functions and helpers)
        $mixins = $this->compileMixins();

        $helpers = '';
        if ($this->options['stand_alone']) {

            $helpers = file_get_contents(__DIR__.'/Compiler/functions.php')."\n?>\n";
            $helpers .= $this->createCode('namespace {');
        }

        //Put everything together
        $phtml = implode('', [$helpers, $mixins, $phtml]);

        if ($this->options['stand_alone'])
            $phtml .= $this->createCode('}');

        //Reset the files after compilation so that compileFile may resolve correctly
        //Happens when you call compileFile twice on different files
        //Note that Compiler only uses the include-path, when there is no file in the
        //file name storage $_files
        $this->files = [];

        //Return the compiled PHTML
        return trim($phtml);
    }
public function compile ( $ input , $ path = null ) { //Compiler reset $ this -> files = $ path ? [ $ path ] : [ ] ; $ this -> mixins = [ ] ; $ this -> calledMixins = [ ] ; $ this -> blocks = [ ] ; $ this -> level = 0 ; $ this -> iteratorId = 0 ; $ this -> forceInline = false ; //Parse the input into an AST $ node = null ; try { $ node = $ this -> parser -> parse ( $ input ) ; } catch ( \ Exception $ e ) { //This is needed to be able to keep track of the //file path that is erroring if ( ! ( $ e instanceof Exception ) ) $ this -> throwException ( $ e -> getMessage ( ) ) ; else throw $ e ; } //There are some things we need to take care of before compilation $ this -> handleImports ( $ node ) ; $ this -> handleBlocks ( $ node ) ; $ this -> handleMixins ( $ node ) ; //The actual compilation process ($node is the very root \Tale\Pug\Parser\Node of everything) $ phtml = $ this -> compileNode ( $ node ) ; //Reset the level again for our next operations $ this -> level = 0 ; //Now we append/prepend specific stuff (like mixin functions and helpers) $ mixins = $ this -> compileMixins ( ) ; $ helpers = '' ; if ( $ this -> options [ 'stand_alone' ] ) { $ helpers = file_get_contents ( __DIR__ . '/Compiler/functions.php' ) . "\n?>\n" ; $ helpers .= $ this -> createCode ( 'namespace {' ) ; } //Put everything together $ phtml = implode ( '' , [ $ helpers , $ mixins , $ phtml ] ) ; if ( $ this -> options [ 'stand_alone' ] ) $ phtml .= $ this -> createCode ( '}' ) ; //Reset the files after compilation so that compileFile may resolve correctly //Happens when you call compileFile twice on different files //Note that Compiler only uses the include-path, when there is no file in the //file name storage $_files $ this -> files = [ ] ; //Return the compiled PHTML return trim ( $ phtml ) ; }
Compiles a Pug-string to PHTML.

The result can then be evaluated, the best method is
a simple PHP include

Look at Renderer to get this done for you

If you give it a path, the directory of that path will be used
for relative includes.

@param string      $input the jade input string
@param string|null $path  the path for relative includes

@return mixed|string a PHTML string containing HTML and PHP

@throws Exception when the compilation fails
@throws Parser\Exception when the parsing fails
@throws Lexer\Exception when the lexing fails
Compiles a Pug - string to PHTML .