PHP Класс Basecoat\View

Автор: Brent Baisley ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$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

Открытые методы

Метод Описание
__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 )

Описание методов

__construct() публичный Метод

Create an instance of the Content class
public __construct ( ) : Object
Результат Object instance of Content class

__get() публичный Метод

Getter method for returning a data item
public __get ( String $name ) : Mixed
$name String Name of the data item to return
Результат Mixed value of the data item

__toString() публичный Метод

Return data values as string
public __toString ( ) : String
Результат String values of data items delimited with line feeds

add() публичный Метод

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() публичный Метод

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() публичный Метод

Merge content blocks for this instance with passed instance
public addToView ( View $view ) : integer
$view View Instance to add content blocks to
Результат integer number of content blocks merged

clear() публичный Метод

Clear all content block namespaces and data
public clear ( )

getBlocks() публичный Метод

Get all currently parsed content blocks
public getBlocks ( ) : Array
Результат Array associative array of content blocks

getData() публичный Метод

Get all the data currently loaded
public getData ( ) : Array
Результат Array associative array of loaded data

getLayout() публичный Метод

* 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() публичный Метод

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() публичный Метод

Parse a template into content block namespaces if content block identifiers are present
public parseBlocks ( String $tpl ) : integer
$tpl String template to parse
Результат integer number of content blocks discovered

processTemplate() публичный Метод

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)
Результат String the processed template or the number of content blocks parsed

replaceDataTags() публичный Метод

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
Результат String the processed template with data tags replaced

setLayout() публичный Метод

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

setLayouts() публичный Метод

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() публичный Метод

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

stripDataTags() публичный Метод

public stripDataTags ( &$tpl )

Описание свойств

$block_tag_regex публичное свойство

@block_name
public $block_tag_regex

$blocks публичное свойство

Content "blocks" in template files
public $blocks

$data публичное свойство

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

$data_tags_delimiters публичное свойство

Data tag delimiters
public $data_tags_delimiters

$default_namespace публичное свойство

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

$enable_data_tags публичное свойство

Enable data tag search and replace
public $enable_data_tags

$layout публичное свойство

public $layout

$layouts публичное свойство

Layout template to use
public $layouts

$templates_path публичное свойство

public $templates_path