Properties

$leftDelimiter

$leftDelimiter : string

Left delimiter character for pseudo vars

Type

string

$rightDelimiter

$rightDelimiter : string

Right delimiter character for pseudo vars

Type

string

$noparseBlocks

$noparseBlocks : array

Stores extracted noparse blocks.

Type

array

$plugins

$plugins : array

Stores any plugins registered at run-time.

Type

array

$dataContexts

$dataContexts : array

Stores the context for each data element when set by `setData` so the context is respected.

Type

array

Methods

__construct()

__construct(\Config\View  $config, string  $viewPath = null, mixed  $loader = null, boolean  $debug = null, \CodeIgniter\Log\Logger  $logger = null) 

Constructor

Parameters

\Config\View $config
string $viewPath
mixed $loader
boolean $debug
\CodeIgniter\Log\Logger $logger

render()

render(string  $view, array  $options = null, boolean  $saveData = null) : string

Parse a template

Parses pseudo-variables contained in the specified template view, replacing them with any data that has already been set.

Parameters

string $view
array $options
boolean $saveData

Returns

string

renderString()

renderString(string  $template, array  $options = null, boolean  $saveData = null) : string

Parse a String

Parses pseudo-variables contained in the specified string, replacing them with any data that has already been set.

Parameters

string $template
array $options
boolean $saveData

Returns

string

setData()

setData(array  $data = array(), string  $context = null) : \CodeIgniter\View\RendererInterface

Sets several pieces of view data at once.

In the Parser, we need to store the context here so that the variable is correctly handled within the parsing itself, and contexts (including raw) are respected.

Parameters

array $data
string $context

The context to escape it for: html, css, js, url, raw If 'raw', no escaping will happen

Returns

\CodeIgniter\View\RendererInterface

insertNoparse()

insertNoparse(string  $template) : string

Re-inserts the noparsed contents back into the template.

Parameters

string $template

Returns

string

setDelimiters()

setDelimiters(string  $leftDelimiter = '{', string  $rightDelimiter = '}') : \CodeIgniter\View\RendererInterface

Over-ride the substitution field delimiters.

Parameters

string $leftDelimiter
string $rightDelimiter

Returns

\CodeIgniter\View\RendererInterface

shouldAddEscaping()

shouldAddEscaping(string  $key) : false|string

Checks the placeholder the view provided to see if we need to provide any autoescaping.

Parameters

string $key

Returns

false|string

addPlugin()

addPlugin(string  $alias, callable  $callback, boolean  $isPair = false) : $this

Makes a new plugin available during the parsing of the template.

Parameters

string $alias
callable $callback
boolean $isPair

Returns

$this

removePlugin()

removePlugin(string  $alias) : $this

Removes a plugin from the available plugins.

Parameters

string $alias

Returns

$this

parse()

parse(string  $template, array  $data = array(), array  $options = null) : string

Parse a template

Parses pseudo-variables contained in the specified template, replacing them with the data in the second param

Parameters

string $template
array $data
array $options

Future options

Returns

string

parseSingle()

parseSingle(string  $key, string  $val) : array

Parse a single key/value, extracting it

Parameters

string $key
string $val

Returns

array

parsePair()

parsePair(string  $variable, array  $data, string  $template) : array

Parse a tag pair

Parses tag pairs: {some_tag} string... {/some_tag}

Parameters

string $variable
array $data
string $template

Returns

array

parseComments()

parseComments(string  $template) : string

Removes any comments from the file. Comments are wrapped in {# #} symbols:

{# This is a comment #}

Parameters

string $template

Returns

string

extractNoparse()

extractNoparse(string  $template) : string

Extracts noparse blocks, inserting a hash in its place so that those blocks of the page are not touched by parsing.

Parameters

string $template

Returns

string

parseConditionals()

parseConditionals(string  $template) : string

Parses any conditionals in the code, removing blocks that don't pass so we don't try to parse it later.

Valid conditionals:

  • if
  • elseif
  • else

Parameters

string $template

Returns

string

replaceSingle()

replaceSingle(  $pattern,   $content,   $template, boolean  $escape = false) : string

Handles replacing a pseudo-variable with the actual content. Will double-check for escaping brackets.

Parameters

$pattern
$content
$template
boolean $escape

Returns

string

prepareReplacement()

prepareReplacement(array  $matches, string  $replace, boolean  $escape = true) : string

Callback used during parse() to apply any filters to the value.

Parameters

array $matches
string $replace
boolean $escape

Returns

string

applyFilters()

applyFilters(string  $replace, array  $filters) : string

Given a set of filters, will apply each of the filters in turn to $replace, and return the modified string.

Parameters

string $replace
array $filters

Returns

string

parsePlugins()

parsePlugins(string  $template) : string

Scans the template for any parser plugins, and attempts to execute them.

Plugins are notated based on {+ +} opening and closing braces.

When encountered,

Parameters

string $template

Returns

string

objectToArray()

objectToArray(  $value) : mixed

Converts an object to an array, respecting any toArray() methods on an object.

Parameters

$value

Returns

mixed