\ReflectionTemplate_Block
A class representing a block inside a {@link ReflectionTemplate}. Can intelligently get its parent, child blocks, variables, etc.
- Author: Uncle Cheese <unclecheese@leftandmain.com>
Synopsis
class ReflectionTemplate_Block
extends SS_Object
{
- // members
- protected ReflectionTemplate $reflector;
- protected $allContents;
- protected $blockOuterContents;
- protected $blockInnerContents;
- protected $openingDelimiter;
- protected array $children = ;
- protected $vars;
- protected $possibleBooleans;
- protected $name;
- protected $id;
- protected $type;
- // methods
- public void __construct()
- public void addChild()
- public ReflectionTemplate_Block getParent()
- public array getVars()
- public string getTopLevelContent()
- public void addVar()
- public array getPossibleBooleans()
- public string getName()
- public array getChildren()
- public ReflectionTemplate_Block getChildByName()
- public string getOuterContents()
- public string getInnerContents()
- public int getID()
- public int getRelativeOffset()
- public boolean isRoot()
- public boolean isLoop()
- public boolean isWith()
Hierarchy
Extends
- SS_Object
Members
protected
- $allContents
—
string
The entire contents of the parent template - $blockInnerContents
—
string
The "inner" contents of the block, excluding the delimiters - $blockOuterContents
—
string
The "outer" contents of the block, including the <% .. %> <% end_.. %> delimiters - $children
—
array
A list of the nested blocks - $id
—
int
The ID of this block, or its offset in the parent template string - $name
—
string
The name of this block, e.g. <% loop $Items %> is named "Items" - $openingDelimiter
—
string
The opening syntax for this block, e.g. <% loop $Items.limit(5) %> - $possibleBooleans
—
array
A list of the possible booleans in this block, e.g. <% if .. %>q - $reflector
—
ReflectionTemplate
A reference to the parent {@link ReflectionTemplate} - $type
—
string
The type of block: "loop", "with", or "root" - $vars
—
array
A list of the variables in this block
Methods
public
- __construct() — Constructor. Processes the block and generates the inner/outer contents. Computes the name and the type of block
- addChild() — Adds a child block to this block
- addVar() — Adds a new variable to this block
- getChildByName() — Gets a child block by name
- getChildren() — Gets the direct descendants of this block
- getID() — Gets the identifier, or offset, of this block
- getInnerContents() — Gets the outer contents of the block. Excludes the block delimiters
- getName() — Get the name of this block
- getOuterContents() — Gets the outer contents of the block. Includes the block delimiters
- getParent() — Gets the parent block
- getPossibleBooleans() — Gets a list of the possible booleans in this template, e.g. <% if $SoldOut %>
- getRelativeOffset() — Gets the offset, relative to the parent block
- getTopLevelContent() — Gets all the content at the $Top level. Removes blocks.
- getVars() — Gets all the vars in this block, mapped by $VarName => $Type.
- isLoop() — Returns true if this block is a <% loop %>
- isRoot() — Returns true if this is the $Top block
- isWith() — Returns true if this is a <% with %> block