ContentProcessor
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
The content processor constructor.
Process a file related snippet like `<@ foreach "*.jpg" { options } @> .
Process content variables and optional string functions. Like {[ var | function1 ( parameters ) | function2 | .
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
at line 89
__construct(Automad $Automad, Runtime $Runtime, InPage $InPage, bool $headless)
The content processor constructor.
at line 111
string
processFileSnippet(string $file, array $options, string $snippet, string $directory, bool $collectSnippetDefinitions)
Process a file related snippet like `<@ foreach "*.jpg" { options } @> .
.. <@ end @>`.
at line 183
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().
at line 283
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.