PHP Класс 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');
С версии: 1.0.0-rc1
Автор: Basil Suter ([email protected])
Наследование: extends yii\base\Object
Показать файл Открыть проект Примеры использования класса

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

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

Приватные методы

Метод Описание
addTag ( $identifier, $tagObjectConfig )
evalTag ( $tag, $context )
getInstance ( )
hasTag ( $tag )
instantiatTag ( $tag )
processText ( $text )

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

convert() публичный статический Метод

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.
Результат string The converted output of $text.

convertWithMarkdown() публичный статический Метод

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.
Результат string the COnverted output of $text.

getInstantiatedTagObjects() публичный статический Метод

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
Результат array An array with all tag object available.

inject() публичный статический Метод

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.