PHP Class Yosymfony\Spress\Core\DataSource\Filesystem\AttributeParser

syntaxes supported: YAML and JSON.
Author: Victor Puertas ([email protected])
Show file Open project: spress/spress Class Usage Examples

Public Methods

Method Description
__construct ( string $type = self::PARSER_YAML ) Constructor.
getAttributesFromFrontmatter ( string $value ) : array Get the attributes from the fronmatter of an item. Front-matter block let you specify certain attributes of the page and define new variables that will be available in the content.
getAttributesFromString ( string $value ) : array Get the attributes of an item from string.
getContentFromFrontmatter ( string $value ) : string Get the content without frontmatter block.

Method Details

__construct() public method

Constructor.
public __construct ( string $type = self::PARSER_YAML )
$type string Type of parser: "yaml" or "json"

getAttributesFromFrontmatter() public method

e.g: (YAML syntax) --- name: "Victor" ---
public getAttributesFromFrontmatter ( string $value ) : array
$value string Frontmatter
return array Array with two elements: "attributes" and "content"

getAttributesFromString() public method

Get the attributes of an item from string.
public getAttributesFromString ( string $value ) : array
$value string Attributes represented as string. e.g: JSON or YAML
return array

getContentFromFrontmatter() public method

Get the content without frontmatter block.
public getContentFromFrontmatter ( string $value ) : string
$value string Frontmatter
return string