Class: Block

Block

Block Object use to store html and template data and render them

new Block(layout, options)

Constructor
Parameters:
Name Type Description
layout Layout Layout instance
options Object Block options
Properties
Name Type Description
name string Block name
html string Block html
config BlockConfig Block config
parent string Block parnet name
template string Block tamplate path
cache Cache Cache instance

Members


config :Object

Config object
Type:
  • Object

data :string

Block data object, it's the object passed to twig for render
Type:
  • string

html :string

Block html
Type:
  • string

layout :Layout

Layout instance
Type:

name :string

Block name
Type:
  • string

page :string|null

Block page path
Type:
  • string | null

parent :string

block parent name take from config or options
Type:
  • string

template :string

template path
Type:
  • string

Methods


addBlocks(blocks)

Add many blocks
Parameters:
Name Type Description
blocks Array blocks configs array

<async> afterInitChildren()

afterLoadChrildren hook called after all blocks are loaded

<async> afterLoad()

AfterLoad hook called after all blocks are loaded

<async> beforeRender()

beforeRender hook Call before the render

getBlock(name)

Get a block instance by name
Parameters:
Name Type Description
name string Block name
Returns:
Block instance
Type
Block

getChildrenBlock()

return the children block to load after this block init

<async> init()

Init callback call at the end of construct

<async> isCached()

Check if the block render is cached
Returns:
Type
Boolean

<async> render()

Render the block Render the children blocks and the block
Returns:
Block html rendered
Type
string