{* This is a comment *} {ignore}This is another comment{/ignore}

Test Myth TPL {#self::VERSION}


Variables

Variable: {$variable}

Init Variable {$v = 10}

Show Variable {$v}

Modifier {$variable|strlen}

Cascade Modifier {$variable|substr:2,5|strlen}

Scoping (object) {$user->name}

Scoping (array) {$week.0}

Variable as key {$week[$numbers.0]}

Var test {$variable}


String test {function="date('Y-m-d')"}

{if="$num1 == 10 || $num1 == 20"} num1 is in wanted values
{/if} String test 2 {#"Y-m-d H:i:s"|date:4108722722}

String test 2 {#"Y-m-d H:i:s"}

{loop="$week"}{$variable}
{/loop}

Ternary Operator

The title is: {isset($title)?"$title":'default title'}

Loop

Simple Loop

Modifier on Loop

Simple Nested Loop

Loop on created array

If

True condition: {if="true"}This is true{/if}

Modifier inside if: {if="$variable|is_string"}True{/if}

Function test

Simple function: {function="time"}

Function with parameters: {function="date('d-m-Y')"}

Static method: {function="\Test::method('123test')"}

Escape Text

Malicious content: {autoescape="on"}{$bad_text}{/autoescape}

Custom tag

{@message to translate@}

Custom tag 2

{%message to translate|english%}

Escape variable with autoescape

{autoescape="on"}{$bad_variable}{/autoescape} {autoescape="off"}{$safe_variable}{/autoescape}

Escape variable with modifiers

{$bad_variable|escape}

More modifier examples

{#'this IS a STring I╲⟍⎝╲༼◕ ◕ ༽╱⎠⟋╱I'|strtolower|ucwords|escape:"UTF-8"}
{#'simple string'|test_modifier:"not such a ", " is it?"}

{noparse}{php}{/noparse} Tag status: {$this->getTagPhp() ? 'enabled' : 'disabled'}

{php} // if the PHP tag is not active, this will be treated as the {ignore} tag echo 'This message is generated by PHP code embedded in the template. If the {php} tag is disabled, this text will not be processed!'; echo '
'; echo 'Note that the code in the {php} tag is executed inside the MythTPL object context so you will need to use "global $variable;" or "$GLOBALS["variable"]" super var to access data from the app'; {/php}