Properties

$extensions

$extensions : array

List of global extensions. Class names that add custom behaviors to the engine.

Type

array

$filters

$filters : array

List of global filters stored as array where keys are filter names, and values the action callback.

Type

array

$keywords

$keywords : array

List of global custom keywords stored as array where keys are keyword names, and values the action callback.

Type

array

$renderer

$renderer : \Phug\Renderer

The current rendering instance used for ::compile(File,Directory), ::render(File,Directory), ::display(File).

Type

\Phug\Renderer

$rendererClassName

$rendererClassName : \Phug\Renderer

Rendering class to be used to create the renderer engine.

Type

\Phug\Renderer

Methods

getExtensionsOptions()

getExtensionsOptions(array  $extensions, array  $options = array()) : array

Get options from extensions list and default options.

Parameters

array $extensions

list of extensions instances of class names

array $options

optional default options to merge with

Returns

array

hasExtension()

hasExtension(string  $extensionClassName) : boolean

Check if an extension is available globally.

Parameters

string $extensionClassName

Returns

boolean

addExtension()

addExtension(string  $extensionClassName) 

Add an extension to the Phug facade (will be available in the current renderer instance and next static calls).

Throws an exception if the extension is not a valid class name.

Parameters

string $extensionClassName

Throws

\Phug\PhugException

removeExtension()

removeExtension(string  $extensionClassName) 

Remove an extension from the Phug facade (remove from current renderer instance).

Parameters

string $extensionClassName

getExtensions()

getExtensions() : array

Get extensions list added through the Phug facade.

Returns

array

getExtensionIds()

getExtensionIds() : array

Get extensions list added through the Phug facade as normalized names.

Returns

array

setRendererClassName()

setRendererClassName(string  $rendererClassName) 

Set the engine class used to render templates.

Parameters

string $rendererClassName

class name of the custom renderer engine

Examples

** File not found : Phug::setRendererClassName(\Tale\Pug\Renderer::class) **
** File not found : Phug::setRendererClassName(\Pug\Pug::class) **

getRendererClassName()

getRendererClassName() : string

Get the current engine class used to render templates.

Returns

string —

$rendererClassName class name of the custom renderer engine

removeOptions()

removeOptions(array  $path, mixed  $options) 

Cleanup previously set options.

Parameters

array $path

option base path

mixed $options

options to remove

Examples

['coffee' => null]])
** File not found : Phug::removeOptions(['filters'], **

reset()

reset() 

Reset all static options, filters and extensions.

getRenderer()

getRenderer(array  $options = array()) : \Phug\Renderer

Get a renderer with global options and argument options merged.

Parameters

array $options

Returns

\Phug\Renderer

Examples

** File not found : Phug::getRenderer([]) **

isRendererInitialized()

isRendererInitialized() : boolean

Return true if the facade already created a Renderer instance.

Returns

boolean

render()

render(string  $input, array  $parameters = array(), array  $options = array()) : string

Return a rendered Pug template string.

Parameters

string $input

pug source

array $parameters

variables values

array $options

custom options

Returns

string

renderFile()

renderFile(string  $path, array  $parameters = array(), array  $options = array()) : string

Return a rendered Pug file.

Parameters

string $path

path to template

array $parameters

variables values

array $options

custom options

Returns

string

display()

display(string  $input, array  $parameters = array(), array  $options = array()) 

Display a rendered Pug template string. By default, it means HTML output to the buffer.

Parameters

string $input

pug source

array $parameters

variables values

array $options

custom options

displayFile()

displayFile(string  $path, array  $parameters = array(), array  $options = array()) 

Display a rendered Pug file. By default, it means HTML output to the buffer.

Parameters

string $path

path to template

array $parameters

variables values

array $options

custom options

hasFilter()

hasFilter(string  $name) : boolean

Check if a filter is available globally.

Parameters

string $name

Returns

boolean

getFilter()

getFilter(string  $name) : callable

Get a global filter by name.

Parameters

string $name

Returns

callable

setFilter()

setFilter(string  $name, callable|string  $filter) 

Set a filter to the Phug facade (will be available in the current renderer instance and next static calls).

Throws an exception if the filter is not callable and do not have a parse method.

Parameters

string $name
callable|string $filter

Throws

\Phug\PhugException

addFilter()

addFilter(string  $name, callable|string  $filter) 

Add a filter. Throws an exception if the name is already taken.

Parameters

string $name
callable|string $filter

Throws

\Phug\PhugException

replaceFilter()

replaceFilter(string  $name, callable|string  $filter) 

Replace a filter. Throws an exception if the name is set.

Parameters

string $name
callable|string $filter

Throws

\Phug\PhugException

removeFilter()

removeFilter(string  $name) 

Remove a filter from the Phug facade (remove from current renderer instance).

Parameters

string $name

getFilters()

getFilters() : array

Get filters list added through the Phug facade.

Returns

array

hasKeyword()

hasKeyword(string  $name) : boolean

Check if a keyword is available globally.

Parameters

string $name

Returns

boolean

getKeyword()

getKeyword(string  $name) : callable

Get a global custom keyword by name.

Parameters

string $name

Returns

callable

setKeyword()

setKeyword(string  $name, callable|string  $keyword) 

Set a keyword to the Phug facade (will be available in the current renderer instance and next static calls).

Throws an exception if the keyword is not callable.

Parameters

string $name
callable|string $keyword

Throws

\Phug\PhugException

addKeyword()

addKeyword(string  $name, callable|string  $keyword) 

Add a keyword. Throws an exception if the name is already taken.

Parameters

string $name
callable|string $keyword

Throws

\Phug\PhugException

replaceKeyword()

replaceKeyword(string  $name, callable|string  $keyword) 

Replace a keyword. Throws an exception if the name is set.

Parameters

string $name
callable|string $keyword

Throws

\Phug\PhugException

removeKeyword()

removeKeyword(string  $name) 

Remove a keyword from the Phug facade (remove from current renderer instance).

Parameters

string $name

getKeywords()

getKeywords() : array

Get keywords list added through the Phug facade.

Returns

array

cacheDirectory()

cacheDirectory(string|array  $source, string|null  $destination = null, array|null  $options = null) : array

Cache a whole directory and return an array with [$successCount, $errorCount, $errorDetails].

Parameters

string|array $source

input directories containing pug files

string|null $destination

output for compiled PHP files (if array given, will be used as options array)

array|null $options

optional options

Throws

\Phug\RendererException

Returns

array

textualCacheDirectory()

textualCacheDirectory(string  $source, string|null  $destination = null, array|null  $options = null) : string

Same method as cacheDirectory but with textual human-friendly output.

Parameters

string $source

input directories containing pug files

string|null $destination

output for compiled PHP files (if array given, will be used as options array)

array|null $options

optional options

Throws

\Phug\RendererException

Returns

string

__callStatic()

__callStatic(  $name,   $arguments) : mixed

All dynamic methods from the renderer can be called statically with Phug facade.

Parameters

$name
$arguments

Returns

mixed

normalizeExtensionClassName()

normalizeExtensionClassName(  $name) 

Parameters

$name

normalizeFilterName()

normalizeFilterName(  $name) 

Parameters

$name

normalizeKeywordName()

normalizeKeywordName(  $name) 

Parameters

$name

resetFacadeOptions()

resetFacadeOptions() 

callOption()

callOption(  $method, array  $arguments) 

Parameters

$method
array $arguments

isOptionMethod()

isOptionMethod(  $method) 

Parameters

$method

getFacadeOptions()

getFacadeOptions() 

getExtensionsGetters()

getExtensionsGetters() 

resolveExtension()

resolveExtension(  $extensionClassName) 

Parameters

$extensionClassName

getExtensionMethodResult()

getExtensionMethodResult(  $extensionClassName,   $method) 

Parameters

$extensionClassName
$method

removeExtensionFromCurrentRenderer()

removeExtensionFromCurrentRenderer(  $extensionClassName) 

Parameters

$extensionClassName

mergeOptions()

mergeOptions(  $options,   $values) 

Parameters

$options
$values

extractExtensionOptions()

extractExtensionOptions(  $options,   $extensionClassName,   $methods) 

Parameters

$options
$extensionClassName
$methods

getOptions()

getOptions(array  $options = array()) 

Parameters

array $options