Class: Layout

Layout

Layout Class Manage blocks

new Layout(options)

Parameters:
Name Type Description
options Object Layout options
Properties
Name Type Description
cache Cache Cache instance
tmpDir string temp dir to write block in file and require them
views string Path to the views dir

Members


blocks :Object

Store blocks instance by name
Type:
  • Object

renderPage :boolen

Define if render a page or juste template block
Type:
  • boolen

Methods


<async> _afterInitBlock(block)

Call afterInit callback and load child block
Parameters:
Name Type Description
block *

<async> _cacheFile(filename, content)

Parameters:
Name Type Description
filename *
content *

<async> _cacheTemplate(template, content)

Put the html and the script in a cache file
Parameters:
Name Type Description
template *
content *

<async> _getCacheFile(filename)

Parameters:
Name Type Description
filename *

<async> _loadFileTemplate(template)

Open a template file search for template and script tags return and object with html and scipt
Parameters:
Name Type Description
template String tamplate path
Returns:
Type
Object

<async> createBlock(options)

Create a Block instance
Parameters:
Name Type Description
options Object block params
Returns:
Block

extendTwigFilter(name, filter)

Extend twig filter
Parameters:
Name Type Description
name String filter name
filter function filter function

<async> extendTwigFilters(extendFilters)

Extend twig filters
Parameters:
Name Type Description
extendFilters Object filters object {name: filter function, ...}

extendTwigFunction(name, fn)

Extend twig function
Parameters:
Name Type Description
name String function name
fn function function

<async> extendTwigFunctions(extendFilters)

Extend twig functions
Parameters:
Name Type Description
extendFilters Object filters object {name: filter function, ...}

getBlock(name)

Return a Block instance by name
Parameters:
Name Type Description
name Sting block name
Returns:
Block

<async> getBlockHtml(name)

Return the block html
Parameters:
Name Type Description
name Sting block name
Returns:
Type
String

<async> init()

Extend twig and init cache

<async> loadTemplate(template, config)

Load a template file
Parameters:
Name Type Description
template string Template path relative to the views dir
config Object Block config
Properties
Name Type Description
script Object Block script path

<async> render()

Render the block page
Returns:
Type
string

<async> renderBlocks(parent)

Render child blocks of the parent and return and object contain blocks html
Parameters:
Name Type Description
parent string block parent name
Returns:
Object

<async> renderFile(file, data)

Render a template file
Parameters:
Name Type Description
file string template path
data Object data object of the template
Returns:
String

<async> renderHtml(html, data)

Render a html template with twig
Parameters:
Name Type Description
html string html to render
data Object data object of the template
Returns:
String