PHP Class luya\TagParser

This is an additional concept to markdown, where you can inject your custom tags to parse. All tags must be an instance of luya\tag\BaseTag and implement the parse($value, $sub) method in order to convert the input to your tag. Read more in the Guide [[concept-tags.md]]. The identifier of the tag is not related to your tag, so you can configure the same tag as different names with multiple purposes. To inject a created tag just use: php TagParser::inject('tagname', ['class' => 'path\to\TagClass']); To parse text with or without markdown use: php TagParser::convert('Hello tagnamevalue'); TagParser::convertWithMarkdown('**Hello** tagnamevalue');
Since: 1.0.0-rc1
Author: Basil Suter ([email protected])
Inheritance: extends yii\base\Object
显示文件 Open project: luyadev/luya Class Usage Examples

Public Methods

Method Description
convert ( string $text ) : string Convert the CMS-Tags into HTML-Tags.
convertWithMarkdown ( string $text ) : string Convert the CMS-Tags into HTMl-Tags and additional convert GFM Markdown into Html as well. The main purpose of this method to fix the conflict between markdown and tag parser when using urls.
getInstantiatedTagObjects ( ) : array Generate the instance for all registered tags.
inject ( string $name, string | array $config ) Inject a new tag with a given name and a configurable array config.

Private Methods

Method Description
addTag ( $identifier, $tagObjectConfig )
evalTag ( $tag, $context )
getInstance ( )
hasTag ( $tag )
instantiatTag ( $tag )
processText ( $text )

Method Details

convert() public static method

Convert the CMS-Tags into HTML-Tags.
public static convert ( string $text ) : string
$text string The content where the CMS-Tags should be found and convert into Html-Tags.
return string The converted output of $text.

convertWithMarkdown() public static method

Convert the CMS-Tags into HTMl-Tags and additional convert GFM Markdown into Html as well. The main purpose of this method to fix the conflict between markdown and tag parser when using urls.
public static convertWithMarkdown ( string $text ) : string
$text string The content where the CMS-Tags should be found and convert into Html-Tags and Markdown Tags.
return string the COnverted output of $text.

getInstantiatedTagObjects() public static method

The main purpose of this method is to return all tag objects in admin context to provide help informations from the tags.
public static getInstantiatedTagObjects ( ) : array
return array An array with all tag object available.

inject() public static method

Inject a new tag with a given name and a configurable array config.
public static inject ( string $name, string | array $config )
$name string The name of the tag on what the tag should be found. Must be [a-z] chars.
$config string | array The configurable object context can be either a string with a class or a configurable array base on yii\base\Object concept.