PHP Class Simpletags, 68kb

A simple tag parsing library.
Exibir arquivo Open project: 68kb/68kb Class Usage Examples

Public Methods

Method Description
__construct ( $config = [] ) : void Constructor
parse ( $content, $data = [], $callback = [] ) : mixed Parse
parse_globals ( $content, $data ) : string Parse Globals
set_delimiters ( $left, $right ) : object Set Delimiters
set_trigger ( $trigger ) : object Set Trigger

Private Methods

Method Description
_force_array ( $var, $level = 1 ) : array Forces normal multi-dimensional arrays and objects into an array structure that will work with EE/Mojo/CI Parsers.
_parse_attributes ( $attributes ) : array Parse Attributes
_parse_data_double ( $tag, $data ) : mixed Get the data pertaining to the given double tag. This will loop through arrays of given data
_parse_data_single ( $tag, $data ) : mixed Get the data pertaining to the given single tag.
_parse_lang ( $content ) : mixed Parse any language strings
_parse_lang_single ( $tag ) : string Parse the lang lines
_parse_segments ( $segments ) : array Parse Segments

Method Details

__construct() public method

Constructor
public __construct ( $config = [] ) : void
return void

parse() public method

Parses the content and returns an array with marked content and tags or the resulting content from calling the callback for each tag.
public parse ( $content, $data = [], $callback = [] ) : mixed
return mixed Either the tags as array or callback results

parse_globals() public method

Parses global data tags. These are tags that do not use a trigger and have a variable in the $data array. This enables you to use globals inside of other tags: The Tag: {tag:blog:posts offset="{offset}"} The data array: array( 'offset' => $this->uri->segment(3), );
public parse_globals ( $content, $data ) : string
return string The parsed content

set_delimiters() public method

Set the delimeters for the tags
public set_delimiters ( $left, $right ) : object
return object Returns $this to enable method chaining

set_trigger() public method

Sets the tag trigger to use. This allows you to only consider tags that have a trigger: {tag:name}{/tag:name}
public set_trigger ( $trigger ) : object
return object Returns $this to enable method chaining