class ContentProcessor (View source)

The content processor class.

Properties

private $Automad The main Automad instance.
private $headless A boolean variable that contains the headless state
private $InPage The InPage instance.
private $Runtime The Runtime instance.

Methods

__construct(Automad $Automad, Runtime $Runtime, InPage $InPage, bool $headless)

The content processor constructor.

string
processFileSnippet(string $file, array $options, string $snippet, string $directory, bool $collectSnippetDefinitions)

Process a file related snippet like `<@ foreach "*.jpg" { options } @> .

string
processVariables(string $str, bool $isOptionString = false, bool $inPageEdit = false)

Process content variables and optional string functions. Like {[ var | function1 ( parameters ) | function2 | .

string
getValue(string $key)

Get the value of a given variable key depending on the current context - either from the page data, the system variables or from the $_GET array.

Details

__construct(Automad $Automad, Runtime $Runtime, InPage $InPage, bool $headless)

The content processor constructor.

Parameters

Automad $Automad
Runtime $Runtime
InPage $InPage
bool $headless

string processFileSnippet(string $file, array $options, string $snippet, string $directory, bool $collectSnippetDefinitions)

Process a file related snippet like `<@ foreach "*.jpg" { options } @> .

.. <@ end @>`.

Parameters

string $file
array $options
string $snippet
string $directory
bool $collectSnippetDefinitions

Return Value

string the processed file snippet

string processVariables(string $str, bool $isOptionString = false, bool $inPageEdit = false)

Process content variables and optional string functions. Like {[ var | function1 ( parameters ) | function2 | .

.. ]}

Find and replace all variables within $str with values from either the context page data array or, if not defined there, from the shared data array, or from the $_GET array (only those starting with a "?").

By first checking the page data (handled by the Page class), basically all shared data variables can be easily overridden by a page. Optionally all values can be parsed as "JSON safe" ($isOptionString), by escaping all quotes and wrapping variable is quotes when needed. In case a variable is used as an option value for a method and is not part of a string, that variable doesn't need to be wrapped in double quotes to work within the JSON string - the double quotes get added automatically.

By setting $inPageEdit to true, for every processed variable, a temporary markup for an edit button is appended to the actual value. That temporary button still has to be processed later by calling processInPageEditButtons().

Parameters

string $str
bool $isOptionString
bool $inPageEdit

Return Value

string The processed $str

private string getValue(string $key)

Get the value of a given variable key depending on the current context - either from the page data, the system variables or from the $_GET array.

Parameters

string $key

Return Value

string The value