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() : string

Get the class the compiler expects for its modules.

Returns

string

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

reset()

reset() 

Reset layout and compilers cache on clone.

__clone()

__clone() 

Reset layout and compilers cache on clone.

getParentCompiler()

getParentCompiler() : \Phug\CompilerInterface|null

Get parent compiler (compiler of the file that included/extended the current file) or null if the file is not compiled via an import.

Returns

\Phug\CompilerInterface|null

setParentCompiler()

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

Set the parent compiler (should be used to declare an import relation such as include/extend).

Parameters

\Phug\CompilerInterface $compiler

Returns

$this

setUpperLocator()

setUpperLocator(\Phug\Compiler\LocatorInterface|null  $upperLocator) 

Set a master locator to use before the internal one.

Parameters

\Phug\Compiler\LocatorInterface|null $upperLocator

locator strategy

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

normalizePath()

normalizePath(string  $path) : string

Normalize the string of a relative or absolute path.

Parameters

string $path

the path to normalize.

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

The the paths imported (stored in local memory) by a given path.

Parameters

string|null $path

Returns

array

getCurrentImportPaths()

getCurrentImportPaths() : array

The the paths imported (stored in local memory) for the current path.

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

Get the current file path compiling.

Returns

string

hasFilter()

hasFilter(string  $name) : boolean

Check if a filter is in use in the compiler.

Parameters

string $name

Returns

boolean

getFilter()

getFilter(string  $name) : callable|mixed|null

Get a filter by name.

Parameters

string $name

Returns

callable|mixed|null

setFilter()

setFilter(string  $name, callable  $filter) : \Phug\Compiler|\Phug\CompilerInterface

Set a filter for the current compiler.

Parameters

string $name
callable $filter

Returns

\Phug\Compiler|\Phug\CompilerInterface

unsetFilter()

unsetFilter(string  $name) : \Phug\Compiler|\Phug\CompilerInterface

Remove a filter from the compiler.

Parameters

string $name

Returns

\Phug\Compiler|\Phug\CompilerInterface

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|\Closure  $message, null  $node = null, integer  $code, null  $previous = null) 

Throw an exception if given condition is false.

Parameters

boolean $condition

condition to validate

string|\Closure $message

message to throw if condition isn't validated or a closure that returns it

null $node

optional node to get code position in error details

integer $code

optional error code

null $previous

optional link to previous exception

Throws

\Phug\CompilerException

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

initializeFormatter()

initializeFormatter() : \Phug\Formatter

Create the instance of formatter.

Returns

\Phug\Formatter