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.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$content | string |
string
|
public
endBlock (boolean $append = false
)
: void
Closes the layout block.
This captures all buffered output as the block's content, and ends output buffering.
Property | Type | Description |
---|---|---|
$append | boolean |
boolean
|
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.
Property | Type | Description |
---|---|---|
$append | boolean |
boolean
|
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.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$default | mixed |
mixed
|
public getBlockStack () : array
Gets the block stack at this point.
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.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$default | mixed |
mixed
|
public put (string $name) : void
Helper method for the "startBlock" templating function.
Property | Type | Description |
---|---|---|
$name | string |
string
|
public reset () : void
Clears all the registered blocks.
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.
Property | Type | Description |
---|---|---|
$name | string |
string
|
$content | string |
string
|
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.
Property | Type | Description |
---|---|---|
$name | string |
string
|