Chapter 7. Formatting Engine

Midgard adds a new language construct to PHP which allows you to include the value of a variable in HTML without using a <? echo $var; ?> construct.

You can now simply use &(variablename); directly in HTML. Note the absence of the "$".

Object variables that would normally be accessed in PHP code as $object->field can be inserted as &(object.field);.

The way the value is formatted can be specified by adding a modifier after the variable name: &(variable:modifier);. The modifiers are:

Inline variable display modifiers

h : Add value as HTML.

  • Escapes " to &quot; ; & to &amp; ; < to &lt; and > to &gt;.

  • Everything between [< and >] is added verbatim with the [< and >] dropped. PHP code embedded in such a section is executed.

H : Add value as HTML.

  • Everything is included verbatim.

f : Add value as formatted text, the plain text input is formatted as HTML on the fly.

  • Lines starting with "-" will be transformed to unnumbered lists,

  • Paragraphs delimited by an empty line will be surrounded by <p> and </p>.

  • Everything between [< and >] is added verbatim with the [< and >] dropped. PHP code embedded in such a section is executed.

F : Add value as formatted text, the plain text input is formatted as HTML on the fly.

  • Lines starting with "-" will be transformed to unnumbered lists,

  • Paragraphs delimited by an empty line will be surrounded by <p> and </p>.

  • Lines after an empty line with less than 10 words that do not end in a period are formatted as <h2>.

  • Everything between [< and >] is added verbatim with the [< and >] dropped. PHP code embedded in such a section is executed.

p : Execute a value as PHP.

Executes the value of the variable.

u : Add the value urlencoded.

  • Replaces non-safe URI characters with their %code equivalents.