BlockBuilder

Block manager

 class Winter\Storm\Html\BlockBuilder

Properties

protected $blockStack : array

The block stack.

protected $blocks : array

Registered block contents, keyed by block name.

Methods

public append (string $name, string $content) : void

Appends content to a layout block.

Output buffering is not used for this method.

Parameters
Property Description
$name
string
$content
string
Returns
void

public endBlock (boolean $append = false) : void

Closes the layout block.

This captures all buffered output as the block's content, and ends output buffering.

Parameters
Property Description
$append
boolean
Returns
void

public endPut (boolean $append = false) : void

Helper method for the "endBlock" templating function.

If $append is true, the new content should be appended to an existing block, as opposed to overwriting any previous content.

Parameters
Property Description
$append
boolean
Returns
void

public get (string $name, $default = null) : string | null

Returns the layout block contents of a given name, but does not delete it from memory.

If the block does not exist, then the $default content will be returned instead.

Parameters
Property Description
$name
string
$default
mixed
Returns
string | null

public getBlockStack () : array

Gets the block stack at this point.

Returns
array

public placeholder (string $name, $default = null) : string | null

Returns the layout block contents of a given block name and deletes the block from memory.

If the block does not exist, then the $default content will be returned instead.

Parameters
Property Description
$name
string
$default
mixed
Returns
string | null

public put (string $name) : void

Helper method for the "startBlock" templating function.

Parameters
Property Description
$name
string
Returns
void

public reset () : void

Clears all the registered blocks.

Returns
void

public set (string $name, string $content) : void

Sets a content of the layout block, overwriting any previous content for that block.

Output buffering is not used for this method.

Parameters
Property Description
$name
string
$content
string
Returns
void

public startBlock (string $name) : void

Begins the layout block for a given block name.

This method enables output buffering, so all output will be captured as a part of this block.

Parameters
Property Description
$name
string
Returns
void
Copyright © 2024 Winter CMS