PHP Class Basecoat\View

Author: Brent Baisley ([email protected])
Datei anzeigen Open project: shutterstock/basecoat Class Usage Examples

Public Properties

Property Type Description
$block_tag_regex @block_name
$blocks Content "blocks" in template files
$data Name/value pairing of data tags available to templates
$data_tags_delimiters Data tag delimiters
$default_namespace Namespace to place content in if none is specified
$enable_data_tags Enable data tag search and replace
$layout
$layouts Layout template to use
$templates_path

Public Methods

Method Description
__construct ( ) : Object Create an instance of the Content class
__get ( String $name ) : Mixed Getter method for returning a data item
__toString ( ) : String Return data values as string
add ( String $name, Mixed $content, boolean $append = true ) Add content under the namespace By default append to any existing data item with same namespace
addBlock ( String $block_name, String $content ) Add a content block under a specified namespace
addToView ( View $view ) : integer Merge content blocks for this instance with passed instance
clear ( ) Clear all content block namespaces and data
getBlocks ( ) : Array Get all currently parsed content blocks
getData ( ) : Array Get all the data currently loaded
getLayout ( $layout_name = null ) * Get the relative path to a layout file. Default is layout set with setLayout().
multiadd ( Array $name_vals, String $prefix = null ) Add multiple content under multiple namespaces Optionally provide a prefix to be prepended to each namespace name
parseBlocks ( String $tpl ) : integer Parse a template into content block namespaces if content block identifiers are present
processTemplate ( String $tpl, boolean $parse = true ) : String Load and process a content template, optionally parse content blocks into namespaces
replaceDataTags ( String &$tpl ) : String Search and replace data tags in templates Allows usage of {{:data}} tags to output data instead of having to use
setLayout ( $layout_name ) * Set the layout to use for output. Name must match one set with setLayouts().
setLayouts ( $layouts, $default = null ) * Load the list of layouts. An associative array where the key is the layout name and the value is the relative path to the layout file from the templates directory.
setTemplatesPath ( String $path ) Path to templates directory. Use as a prefix when referencing templates and layouts.
stripDataTags ( &$tpl )

Method Details

__construct() public method

Create an instance of the Content class
public __construct ( ) : Object
return Object instance of Content class

__get() public method

Getter method for returning a data item
public __get ( String $name ) : Mixed
$name String Name of the data item to return
return Mixed value of the data item

__toString() public method

Return data values as string
public __toString ( ) : String
return String values of data items delimited with line feeds

add() public method

Add content under the namespace By default append to any existing data item with same namespace
public add ( String $name, Mixed $content, boolean $append = true )
$name String namespace to add content under
$content Mixed content to any under the namespace, can be any data structure
$append boolean whether or not to append the content to the namespace if namespace already exists

addBlock() public method

Add a content block under a specified namespace
public addBlock ( String $block_name, String $content )
$block_name String namespace to add content block under
$content String content to add

addToView() public method

Merge content blocks for this instance with passed instance
public addToView ( View $view ) : integer
$view View Instance to add content blocks to
return integer number of content blocks merged

clear() public method

Clear all content block namespaces and data
public clear ( )

getBlocks() public method

Get all currently parsed content blocks
public getBlocks ( ) : Array
return Array associative array of content blocks

getData() public method

Get all the data currently loaded
public getData ( ) : Array
return Array associative array of loaded data

getLayout() public method

* Get the relative path to a layout file. Default is layout set with setLayout().
public getLayout ( $layout_name = null )
$layout_name name of layout

multiadd() public method

Add multiple content under multiple namespaces Optionally provide a prefix to be prepended to each namespace name
public multiadd ( Array $name_vals, String $prefix = null )
$name_vals Array array of name/value pairs to add
$prefix String prefix to prepend to each namespace name

parseBlocks() public method

Parse a template into content block namespaces if content block identifiers are present
public parseBlocks ( String $tpl ) : integer
$tpl String template to parse
return integer number of content blocks discovered

processTemplate() public method

Load and process a content template, optionally parse content blocks into namespaces
public processTemplate ( String $tpl, boolean $parse = true ) : String
$tpl String template file to include
$parse boolean whether to parse the template blocks into namespaces (default true)
return String the processed template or the number of content blocks parsed

replaceDataTags() public method

Search and replace data tags in templates Allows usage of {{:data}} tags to output data instead of having to use
public replaceDataTags ( String &$tpl ) : String
$tpl String template text to search and replace data tags on
return String the processed template with data tags replaced

setLayout() public method

* Set the layout to use for output. Name must match one set with setLayouts().
public setLayout ( $layout_name )
$layout_name name of layout

setLayouts() public method

Optionally pass name of default layout.
public setLayouts ( $layouts, $default = null )
$layouts associative array of layouts names and relative paths
$default name of layout to set as default

setTemplatesPath() public method

Path to templates directory. Use as a prefix when referencing templates and layouts.
public setTemplatesPath ( String $path )
$path String valid directory path

stripDataTags() public method

public stripDataTags ( &$tpl )

Property Details

$block_tag_regex public_oe property

@block_name
public $block_tag_regex

$blocks public_oe property

Content "blocks" in template files
public $blocks

$data public_oe property

Name/value pairing of data tags available to templates
public $data

$data_tags_delimiters public_oe property

Data tag delimiters
public $data_tags_delimiters

$default_namespace public_oe property

Namespace to place content in if none is specified
public $default_namespace

$enable_data_tags public_oe property

Enable data tag search and replace
public $enable_data_tags

$layout public_oe property

public $layout

$layouts public_oe property

Layout template to use
public $layouts

$templates_path public_oe property

public $templates_path