Properties

$modules

$modules : \Phug\Util\Partial\array<ModuleInterface>

Type

\Phug\Util\Partial\array

$importNodeYielded

$importNodeYielded : boolean

Type

boolean

$formatters

$formatters : \Phug\array<Formatter>

Type

\Phug\array

$path

$path : string

Type

string

$importPaths

$importPaths : array

Type

array

$nodeCompilers

$nodeCompilers : array

Type

array

$namedCompilers

$namedCompilers : array

Type

array

$namedBlocks

$namedBlocks : \Phug\array[array[Block]]

Type

\Phug\array[array[Block]]

Methods

hasModule()

hasModule(string|\Phug\Util\ModuleInterface  $module) : boolean

Parameters

string|\Phug\Util\ModuleInterface $module

Returns

boolean

getModules()

getModules() : \Phug\Util\Partial\array<ModuleInterface>

Returns

\Phug\Util\Partial\array

getStaticModules()

getStaticModules() : \Phug\Util\Partial\array<string>

Returns

\Phug\Util\Partial\array

addModule()

addModule(string|\Phug\Util\ModuleInterface  $module) : $this

Parameters

string|\Phug\Util\ModuleInterface $module

Returns

$this

addModules()

addModules(\Phug\Util\Partial\array<string|\Phug\Util\Partial\ModuleInterface>  $modules) : $this

Parameters

\Phug\Util\Partial\array $modules

Returns

$this

removeModule()

removeModule(string|\Phug\Util\ModuleInterface  $module) : $this

Parameters

string|\Phug\Util\ModuleInterface $module

Returns

$this

getModuleBaseClassName()

getModuleBaseClassName() 

setImportNode()

setImportNode(\Phug\Parser\NodeInterface  $importNode) : $this

Parameters

\Phug\Parser\NodeInterface $importNode

Returns

$this

setYieldNode()

setYieldNode(\Phug\Parser\NodeInterface  $yieldNode) : $this

Parameters

\Phug\Parser\NodeInterface $yieldNode

Returns

$this

unsetYieldNode()

unsetYieldNode() : $this

Returns

$this

isImportNodeYielded()

isImportNodeYielded() : boolean

Returns

boolean

__construct()

__construct(  $options = null) 

Parameters

$options

__clone()

__clone() 

Reset layout and compilers cache on clone.

setParentCompiler()

setParentCompiler(\Phug\CompilerInterface  $compiler) : $this

Parameters

\Phug\CompilerInterface $compiler

Returns

$this

locate()

locate(string  $path, array  $paths = null) : string|null

Locate a file for a given path. Returns null if not found.

Parameters

string $path
array $paths

Returns

string|null

resolve()

resolve(string  $path, array  $paths = null) : string

Resolve a path using the base directories. Throw an exception if not found.

Parameters

string $path
array $paths

Throws

\Phug\CompilerException

Returns

string

getFileContents()

getFileContents(string  $path) : string

Return the contents for a given file path.

Parameters

string $path

Returns

string

getLayout()

getLayout() : \Phug\Compiler\Layout

Return the current layout extended if set.

Returns

\Phug\Compiler\Layout

setLayout()

setLayout(\Phug\Compiler\Layout  $layout) : $this

Set the current layout to extend.

Parameters

\Phug\Compiler\Layout $layout

layout extended

Returns

$this

getParser()

getParser() : \Phug\Parser

Returns the currently used Parser instance.

Returns

\Phug\Parser

getFormatter()

getFormatter() : \Phug\Formatter

Returns the currently used Formatter instance.

Returns

\Phug\Formatter

setNodeCompiler()

setNodeCompiler(string  $className, \Phug\Compiler\NodeCompilerInterface|string  $handler) : $this

Set the node compiler for a given node class name.

Parameters

string $className

node class name

\Phug\Compiler\NodeCompilerInterface|string $handler

handler

Returns

$this

getBlocksByName()

getBlocksByName(string  $name) : mixed

Return list of blocks for a given name.

Parameters

string $name

Returns

mixed

getBlocks()

getBlocks() : array

Returns lists of blocks grouped by name.

Returns

array

replaceBlock()

replaceBlock(\Phug\Compiler\Element\BlockElement  $block, array  $children = null) 

Replace a block by its nodes.

Parameters

\Phug\Compiler\Element\BlockElement $block
array $children

compileBlocks()

compileBlocks() : $this

Replace each block by its compiled children.

Throws

\Phug\CompilerException

Returns

$this

importBlocks()

importBlocks(array  $blocks) : $this

Import blocks named lists into the compiler.

Parameters

array $blocks

Returns

$this

registerImportPath()

registerImportPath(  $path) : $this

Register a path as an imported path of the current compiling path.

Parameters

$path

Returns

$this

getImportPaths()

getImportPaths(string|null  $path = null) : array

Parameters

string|null $path

Returns

array

getCurrentImportPaths()

getCurrentImportPaths() : array

Returns

array

dump()

dump(string  $input, string  $path = null) : string

Dump a debug tre for a given pug input.

Parameters

string $input

pug input

string $path

optional path of the compiled source

Returns

string

dumpFile()

dumpFile(string  $path) : string

Dump a debug tre for a given pug input.

Parameters

string $path

pug input file

Returns

string

compileDocument()

compileDocument(string  $input, string  $path = null) : null|\Phug\Formatter\ElementInterface

Returns ElementInterface from pug input with all layouts and blocks compiled.

Parameters

string $input

pug input

string $path

optional path of the compiled source

Throws

\Phug\CompilerException

Returns

null|\Phug\Formatter\ElementInterface

compile()

compile(string  $input, string  $path = null) : string

Returns PHTML from pug input.

Parameters

string $input

pug input

string $path

optional path of the compiled source

Returns

string

compileFile()

compileFile(string  $path) : string

Returns PHTML from pug input file.

Parameters

string $path

path of the compiled source

Returns

string

compileIntoElement()

compileIntoElement(string  $input, string  $path = null) : null|\Phug\Formatter\ElementInterface

Returns ElementInterface from pug input.

Parameters

string $input

pug input

string $path

optional path of the compiled source

Throws

\Exception

Returns

null|\Phug\Formatter\ElementInterface

compileFileIntoElement()

compileFileIntoElement(string  $path) : \Phug\Formatter\ElementInterface

Returns ElementInterface from pug input file.

Parameters

string $path

path of the compiled source

Returns

\Phug\Formatter\ElementInterface

getPath()

getPath() : string

Returns

string

hasFilter()

hasFilter(string  $name) : boolean

Parameters

string $name

Returns

boolean

getFilter()

getFilter(string  $name) : callable|null

Parameters

string $name

Returns

callable|null

setFilter()

setFilter(string  $name, callable  $filter) : $this

Parameters

string $name
callable $filter

Returns

$this

unsetFilter()

unsetFilter(string  $name) : $this

Parameters

string $name

Returns

$this

throwException()

throwException(string  $message, \Phug\Parser\NodeInterface  $node = null, integer  $code, \Throwable  $previous = null) 

Throws a compiler-exception.

The current file, line and offset of the exception get automatically appended to the exception

Parameters

string $message

A meaningful error message

\Phug\Parser\NodeInterface $node

Node generating the error

integer $code

Error code

\Throwable $previous

Source error

Throws

\Phug\CompilerException

assert()

assert(boolean  $condition, string  $message, \Phug\Parser\NodeInterface  $node = null, integer  $code, \Throwable  $previous = null) 

Parameters

boolean $condition

Assertion to verify

string $message

Error message to throw if assertion fails

\Phug\Parser\NodeInterface $node

Node generating the error

integer $code

Error code

\Throwable $previous

Source error

initializeFormatter()

initializeFormatter() 

getNamedCompiler()

getNamedCompiler(string  $compiler) : \Phug\Compiler\NodeCompilerInterface

Create a new compiler instance by name or return the previous instance with the same name.

Parameters

string $compiler

name

Returns

\Phug\Compiler\NodeCompilerInterface