Properties

$renderingFile

$renderingFile : string

File currently rendering.

Type

string

$renderer

$renderer : 

Type

$options

$options : \ArrayObject

Type

\ArrayObject

$optionNameHandlers

$optionNameHandlers : array

Type

array

Methods

getRenderingFile()

getRenderingFile() : string

Get file currently rendering.

Returns

string

__construct()

__construct(\Phug\Renderer  $renderer, array|\ArrayObject  $options) 

Parameters

\Phug\Renderer $renderer
array|\ArrayObject $options

getRenderer()

getRenderer() : \Phug\Renderer

Return the renderer the adapter was constructed with.

Returns

\Phug\Renderer

captureBuffer()

captureBuffer(callable  $display) : mixed

Capture buffered output of a callable display action.

Parameters

callable $display

the action that potentially send output to the buffer.

Returns

mixed

render()

render(string  $php, array  $parameters) : string

Return renderer HTML.

Parameters

string $php

PHP srouce code

array $parameters

variables names and values

Returns

string

getOptions()

getOptions() 

{@inheritdoc}

setOptions()

setOptions(  $options) 

{@inheritdoc}

Parameters

$options

setOptionsRecursive()

setOptionsRecursive(  $options) 

{@inheritdoc}

Parameters

$options

setOptionsDefaults()

setOptionsDefaults(  $options = null) 

{@inheritdoc}

Parameters

$options

hasOption()

hasOption(  $name) 

{@inheritdoc}

Parameters

$name

getOption()

getOption(  $name) 

{@inheritdoc}

Parameters

$name

setOption()

setOption(  $name,   $value) 

{@inheritdoc}

Parameters

$name
$value

unsetOption()

unsetOption(  $name) 

{@inheritdoc}

Parameters

$name

addOptionNameHandlers()

addOptionNameHandlers(callable  $handler) 

Parameters

callable $handler

resetOptions()

resetOptions() 

cache()

cache(string  $path, string  $input, callable  $rendered, \Phug\Renderer\Adapter\&bool  $success = null) : string

Return the cached file path after cache optional process.

Parameters

string $path

pug file

string $input

pug input code

callable $rendered

method to compile the source into PHP

\Phug\Renderer\Adapter\&bool $success

reference to a variable to be set to true/false on success/failure

Returns

string

displayCached()

displayCached(string  $path, string  $input, callable  $rendered, array  $variables, \Phug\Renderer\Adapter\&bool  $success = null) 

Display rendered template after optional cache process.

Parameters

string $path

pug file

string $input

pug input code

callable $rendered

method to compile the source into PHP

array $variables

local variables

\Phug\Renderer\Adapter\&bool $success

reference to a variable to be set to true/false on success/failure

cacheFile()

cacheFile(string  $path) : boolean|integer

Cache a template file in the cache directory (even if the cache is up to date).

Returns the number of bytes written in the cache file or false if a failure occurred.

Parameters

string $path

pug file

Returns

boolean|integer

cacheFileIfChanged()

cacheFileIfChanged(string  $path) : boolean|integer

Cache a template file in the cache directory if the cache is obsolete.

Returns true if the cache is up to date and cache not change, else returns the number of bytes written in the cache file or false if a failure occurred.

Parameters

string $path

Returns

boolean|integer

cacheDirectory()

cacheDirectory(array<mixed,string>|string  $directory) : array

Scan a directory recursively for its views, compile them and save them into the cache directory.

Parameters

array<mixed,string>|string $directory

the directory to search pug files in it.

Throws

\Phug\RendererException

Returns

array —

count of cached files and error count

display()

display(string  $__pug_php, array  $__pug_parameters) 

Compile then render a file with given locals.

Parameters

string $__pug_php
array $__pug_parameters

locate()

locate(string  $path, array  $locations, array  $extensions) : string

Translates a given path by searching it in the passed locations and with the passed extensions.

Parameters

string $path

the file path to translate.

array $locations

the directories to search in.

array $extensions

the file extensions to search for (e.g. ['.jd', '.pug'].

Returns

string

cacheFileContents()

cacheFileContents(string  $destination, string  $output, array  $importsMap = array()) : boolean

Write the cache file with the given contents and map of imports.

Parameters

string $destination
string $output
array $importsMap

Returns

boolean

reInitCompiler()

reInitCompiler(\Phug\Renderer  $renderer, array  $events) : \Phug\CompilerInterface

Parameters

\Phug\Renderer $renderer
array $events

Throws

\Phug\RendererException

Returns

\Phug\CompilerInterface

parseCliDirectoriesInput()

parseCliDirectoriesInput(string  $directory) : array<mixed,string>

Return directories list from a directory string as it is allowed in CLI: - directory1/x/y - [directory1/x/y,directory2/z] as an array of strings.

Parameters

string $directory

Returns

array<mixed,string>

compileAndCache()

compileAndCache(\Phug\CompilerInterface  $compiler, string  $path, string  $inputFile) : boolean

Compile a file with a given compiler and cache it.

Parameters

\Phug\CompilerInterface $compiler
string $path
string $inputFile

Returns

boolean

normalizePath()

normalizePath(\Phug\CompilerInterface  $compiler, string  $path, string  $directory) : string

Compile a file with a given compiler and cache it.

Parameters

\Phug\CompilerInterface $compiler
string $path
string $directory

Returns

string

hashPrint()

hashPrint(string  $input) : string

Return a hashed print from input file or content.

Parameters

string $input

Returns

string

getRegistryPathChunks()

getRegistryPathChunks(string  $source, integer|null  $directoryIndex = null) : \Phug\Renderer\Partial\iterable

Yield list of path chunks for registry for a given path.

Parameters

string $source
integer|null $directoryIndex

Returns

\Phug\Renderer\Partial\iterable

getFirstRegistryIndex()

getFirstRegistryIndex(array|null  $registry) : string|false

Return the first value indexed with "i:" prefix as raw cash path.

Parameters

array|null $registry

registry result

Returns

string|false

findCachePathInRegistry()

findCachePathInRegistry(string  $path, array  $registry, array<mixed,string>  $extensions = array()) : string|false

Find the path of a cached file for a given path in a given registry.

Parameters

string $path

path to find in the registry

array $registry

registry data array

array<mixed,string> $extensions

extensions to try to add to the file path if not found

Returns

string|false

findCachePathInRegistryFile()

findCachePathInRegistryFile(string  $path, string  $registryFile, array<mixed,string>  $extensions = array()) : string|false

Find the path of a cached file for a given path in a given registry file (that may not exist).

Parameters

string $path

path to find in the registry

string $registryFile

registry file path

array<mixed,string> $extensions

extensions to try to add to the file path if not found

Returns

string|false

registerCachedFile()

registerCachedFile(  $directoryIndex,   $source,   $cacheFile) 

Parameters

$directoryIndex
$source
$cacheFile

createTemporaryFile()

createTemporaryFile() 

getCompiledFile()

getCompiledFile(  $php) 

Parameters

$php

tryExtensionsOnFileKey()

tryExtensionsOnFileKey(array  $registry, string  $key, array<mixed,string>  $extensions) : boolean|mixed

Try to append extension to find a key in a given array if it's file registry key.

Parameters

array $registry
string $key
array<mixed,string> $extensions

Returns

boolean|mixed

tryExtensions()

tryExtensions(array  $registry, string  $key, array<mixed,string>  $extensions) : boolean|mixed

Try to append extension to find a key in a given array assuming it's file registry key.

Parameters

array $registry
string $key
array<mixed,string> $extensions

Returns

boolean|mixed

findInRegistry()

findInRegistry(string  $path, array  $registry, array<mixed,string>  $extensions) : string|array|false

Find raw entry of a cached file for a given path in a given registry.

Parameters

string $path

path to find in the registry

array $registry

registry data array

array<mixed,string> $extensions

extensions to try to add to the file path if not found

Returns

string|array|false

handleOptionName()

handleOptionName(string  $name) : string

Parameters

string $name

Returns

string

filterTraversable()

filterTraversable(  $values) 

Parameters

$values

setOptionArrays()

setOptionArrays(array  $arrays, string  $functionName) : $this

Parameters

array $arrays
string $functionName

Returns

$this

setDefaultOption()

setDefaultOption(  $key,   $value) 

Parameters

$key
$value

withVariableReference()

withVariableReference(mixed  $variable,   $name, callable  $callback) : \Phug\Util\Partial\&$options

Parameters

mixed $variable
$name
callable $callback

Returns

\Phug\Util\Partial\&$options

withOptionReference()

withOptionReference(  $name, callable  $callback) : \Phug\Util\Partial\&$options

Parameters

$name
callable $callback

Returns

\Phug\Util\Partial\&$options

getRawCachePath()

getRawCachePath(string  $file) : string

Return a file path in the cache for a given name (without extension added).

Parameters

string $file

Returns

string

getCachePath()

getCachePath(string  $name) : string

Return a file path with extension added in the cache for a given name.

Parameters

string $name

Returns

string

hasExpiredImport()

hasExpiredImport(  $sourcePath,   $cachePath) : boolean

Returns true if the path has an expired imports linked.

Parameters

$sourcePath
$cachePath

Returns

boolean

getRegistryPath()

getRegistryPath(string  $path, array<mixed,string>  $extensions = array()) : string|false

Get path from the cache registry (if up_to_date_check set to false only).

Parameters

string $path

required view path.

array<mixed,string> $extensions

optional list of extensions to try.

Returns

string|false —

false if no path registered, the path else.

checkPathExpiration()

checkPathExpiration(  $path) 

Parameters

$path

isCacheUpToDate()

isCacheUpToDate(\Phug\Renderer\Adapter\&string  $path, string  $input = null) : boolean

Return true if the file or content is up to date in the cache folder, false else.

Parameters

\Phug\Renderer\Adapter\&string $path

to be filled

string $input

file or pug code

Returns

boolean

getCacheDirectory()

getCacheDirectory()