App: manual - Page: callback/before
PHP
HTML
callback/before.pad
Result
<table border=1>

<tr>
<th>Name</th>
<th>Salary</th>
<th>Bonus</th>
<th>Total</th>
</tr>

{staff callback='before.php', before}

{first}
<tr>
<td>Totals</td>
<td>{$salaryTotal | %.2f}</td>
<td>{$bonusTotal | %.2f}</td>
<td>{$totalTotal | %.2f}</td>
</tr>
{/first}

<tr align="right" bgcolor="{switch 'yellow', 'pink'}">
<td align="left">{$name | capitalize}</td>
<td>{$salary | %.2f}</td>
<td>{$bonus | %.2f}</td>
<td>{$total | %.2f}</td>
</tr>

{/staff}

</table>


App: manual - Page: callback/demand
PHP
HTML
callback/demand.pad
Result
<table border=1>

<tr>
<th>Name</th>
<th>Salary</th>
<th>Bonus</th>
<th>Total</th>
</tr>

{staff callback='demand.php'}

<tr align="right"
bgcolor="{switch 'yellow', 'pink'}">
<td align="left">{$name | capitalize}</td>
<td>{$salary | %.2f}</td>
<td>{$bonus | %.2f}</td>
<td>{$total | %.2f}</td>
</tr>

{/staff}

<tr>
<td>Totals</td>
<td>{$salaryTotal | %.2f}</td>
<td>{$bonusTotal | %.2f}</td>
<td>{$totalTotal | %.2f}</td>
</tr>

</table>


App: manual - Page: fragments/page_5
PHP
HTML
fragments/page_5.pad
Result
<p>Inside a pass: {code}{switch 'first', 'second'}{/code}</p>
<p>After it: {switch 'first', 'second'}</p>


App: regression/errors - Page: syntax/a_switch_needs_values
PHP
HTML
syntax/a_switch_needs_values.pad
Result
{data 'u'}[1,2]{/data}{u}[{switch}]{/u}


App: regression/framework - Page: check/tags_switch
PHP
check/tags_switch.php
HTML
check/tags_switch.pad
Result
<?php

$users
= array (
0 =>
array (
'name' => 'bob',
'phone' => '555-3425',
),
1 =>
array (
'name' => 'jim',
'phone' => '555-4364',
),
2 =>
array (
'name' => 'joe',
'phone' => '555-3422',
),
3 =>
array (
'name' => 'jerry',
'phone' => '555-4973',
),
);

?>
<table border="1">
{users}
<tr bgcolor="{switch 'pink' , 'orange'}">
<td>{$name}</td>
<td>{$phone}</td>
</tr>
{/users}
</table>


App: regression/framework - Page: lenient/a_bare_switch_alternates_nothing
PHP
lenient/a_bare_switch_alternates_nothing.php
HTML
lenient/a_bare_switch_alternates_nothing.pad
Result
<?php

// The lenient walk under test: with the syntax check off, what cannot run passes the
// value through or yields empty, and the walk carries on.

$padCheckSyntax = FALSE;

?>
{data 'u'}[1,2]{/data}[{u}.{switch}{/u}]


App: regression/framework - Page: passes/a_sandboxed_pass_the_same
PHP
HTML
passes/a_sandboxed_pass_the_same.pad
Result
{code sandbox}{switch 'p','q'}{/code}{switch 'p','q'}


App: regression/framework - Page: passes/a_switch_rotation_is_engine_state_a_plain_pass_rolls_it_back
PHP
HTML
passes/a_switch_rotation_is_engine_state_a_plain_pass_rolls_it_back.pad
Result
{code}{switch 'x','y'}{/code}{switch 'x','y'}


App: regression/framework - Page: tags/switch_alternates_over_three
PHP
HTML
tags/switch_alternates_over_three.pad
Result
{data 'xs'}
[1,2,3]
{/data}
{xs}
{switch 'a', 'b', 'c'},
{/xs}


App: regression/framework - Page: tags/switch_alternates_over_two
PHP
HTML
tags/switch_alternates_over_two.pad
Result
{data 'xs'}
[1,2,3]
{/data}
{xs}
{switch 'a', 'b'},
{/xs}


App: regression/pages - Page: misc/parms
PHP
misc/parms.php
HTML
misc/parms.pad
Result
<?php

$abc
= 'abc';
$xyz = 'xyz';

$name = 'name';
$phone = 'phone';

define ( "xxxx", [ 1, 22, 333, 4444] );

$php_array_parms_1 ['xyz'] = 789;

$php_array_parms_1 ['vars'] [0] ['name'] = 'bob-p1';
$php_array_parms_1 ['vars'] [0] ['phone'] = '555-3425';

$php_array_parms_1 ['vars'] [1] ['name'] = 'jim';
$php_array_parms_1 ['vars'] [1] ['phone'] = '555-4364';

$php_array_parms_1 ['vars'] [2] ['name'] = 'joe';
$php_array_parms_1 ['vars'] [2] ['phone'] = '555-3422';

$php_array_parms_1 ['vars'] [3] ['name'] = 'jerry';
$php_array_parms_1 ['vars'] [3] ['phone'] = '555-4973';

$php_array_parms_1 ['abc'] = 123;

$php_array_vars_1 [0] ['name'] = 'bob-v1';
$php_array_vars_1 [0] ['phone'] = '555-3425';

$php_array_vars_1 [1] ['name'] = 'jim';
$php_array_vars_1 [1] ['phone'] = '555-4364';

$php_array_vars_1 [2] ['name'] = 'joe';
$php_array_vars_1 [2] ['phone'] = '555-3422';

$php_array_vars_1 [3] ['name'] = 'jerry';
$php_array_vars_1 [3] ['phone'] = '555-4973';

$php_array_parms_2 ['xyz'] = 789;

$php_array_parms_2 ['vars'] [0] ['name'] = 'bob-p2';
$php_array_parms_2 ['vars'] [0] ['phone'] = '555-3425';

$php_array_parms_2 ['vars'] [1] ['name'] = 'jim';
$php_array_parms_2 ['vars'] [1] ['phone'] = '555-4364';

$php_array_parms_2 ['vars'] [2] ['name'] = 'joe';
$php_array_parms_2 ['vars'] [2] ['phone'] = '555-3422';

$php_array_parms_2 ['vars'] [3] ['name'] = 'jerry';
$php_array_parms_2 ['vars'] [3] ['phone'] = '555-4973';

$php_array_parms_2 ['abc'] = 123;

$php_array_vars_2 [0] ['name'] = 'bob-v2';
$php_array_vars_2 [0] ['phone'] = '555-3425';

$php_array_vars_2 [1] ['name'] = 'jim';
$php_array_vars_2 [1] ['phone'] = '555-4364';

$php_array_vars_2 [2] ['name'] = 'joe';
$php_array_vars_2 [2] ['phone'] = '555-3422';

$php_array_vars_2 [3] ['name'] = 'jerry';
$php_array_vars_2 [3] ['phone'] = '555-4973';

?>
<h3>constant</h3>

<ul>
{xxxx}
<li>{$xxxx}</li>
{/xxxx}
</ul>


<h3>PHP array 1</h3>

<table border=1>
{php_array_vars_1}
<tr bgcolor="{switch 'pink' , 'orange'}">
<td>{$name}</td>
<td>{$phone}</td>
</tr>
{/php_array_vars_1}
</table>


App: tags - Page: examples/switch/1-stripes
PHP
HTML
examples/switch/1-stripes.pad
Result
{meta title='Striped rows', about='Each row takes the next background from the rotation.'}
<table>
{sequence '1..5', name='row'}
<tr style="background: {switch '#ffffff', '#e8eef7'}"><td>Row {$row}</td></tr>
{/sequence}
</table>


App: tags - Page: examples/switch/2-three
PHP
HTML
examples/switch/2-three.pad
Result
{meta title='A longer rotation, shared', about='Three values cycle; a second switch written alike continues the same rotation.'}
<p>{sequence 4}{switch 'red', 'green', 'blue'} {/sequence}</p>
<p>{sequence 4}{switch 'red', 'green', 'blue'} {/sequence}</p>
<p>{sequence 4}{switch 'red','green','blue'} {/sequence}</p>