The HTML markup for this example:

{% apply escape %}
{{ "{% partial \"calcresult\" %}" }}
{% endapply %}

  The calcresult partial:

{% apply escape %}
{{ "{% if result %}" }}
    The result is {{ "{{ result }}" }}.
{{ "{% else %}" }}
    Click the Calculate button to find the answer.
{{ "{% endif %}" }}{% endapply %}

  The onTest PHP code:

function onTest()
{
    $value1 = input('value1');
    $value2 = input('value2');
    $operation = input('operation');

    switch ($operation) {
        case '+' :
            $this['result'] = $value1 + $value2;
            break;
        case '-' :
            $this['result'] = $value1 - $value2;
            break;
        case '*' :
            $this['result'] = $value1 * $value2;
            break;
        default :
            $this['result'] = $value1 / $value2;
            break;
    }
}