App: manual - Page: lvl_occ/9
PHP
|
HTML
lvl_occ/9.pad
|
Result
|
|
{data 'myJson'} [ { "column": [ 11, 12, 13, 14, 15 ] }, { "column": [ 21, 22, 23, 24, 35 ] }, { "column": [ 31, 32, 33, 34, 35 ] } ] {/data}
{pad data='myJson'} <table border='1'> @start@ <tr> {column} <td>{$column}</td> {/column} </tr> @end@ </table> {/pad}
|
| 11 |
12 |
13 |
14 |
15 |
| 21 |
22 |
23 |
24 |
35 |
| 31 |
32 |
33 |
34 |
35 |
|
App: check - Page: miscellaneous/local
PHP
|
HTML
miscellaneous/local.pad
|
Result
|
|
{content 'myContent'}
<h3>{&departments:option:data}</h3>
<table border=1>
<tr> <th> department </th> <th> manager </th> <th> phone </th> </tr>
@start@ <tr> <td> {$department} </td> <td> {$manager} </td> <td> {$phone} </td> </tr> @end@
</table>
{/content}
{pad data='departments/departments', content='myContent'} {pad data='departments/departments.php', content='myContent'} {pad data='departments/departments.csv', content='myContent'} {pad data='departments/departments.xml', content='myContent'} {pad data='departments/departments.json', content='myContent'} {pad data='departments/departments.yaml', content='myContent'}
|
departments/departments
| department |
manager |
phone |
| IT |
Bob |
555-1111 |
| Kitchen |
Jim |
555-2222 |
| Helpdesk |
Joe |
555-3333 |
| Sales |
Steve |
555-4444 |
| Build |
Jerry |
555-8888 |
departments/departments.php
| department |
manager |
phone |
| IT |
Bob |
555-1111 |
| Kitchen |
Jim |
555-2222 |
| Helpdesk |
Joe |
555-3333 |
| Sales |
Steve |
555-4444 |
| Build |
Jerry |
555-7777 |
departments/departments.csv
| department |
manager |
phone |
| IT |
Bob |
555-1111 |
| Kitchen |
Jim |
555-2222 |
| Helpdesk |
Joe |
555-3333 |
| Sales |
Steve |
555-4444 |
| Build |
Jerry |
555-5555 |
departments/departments.xml
| department |
manager |
phone |
| IT |
Bob |
555-1111 |
| Kitchen |
Jim |
555-2222 |
| Helpdesk |
Joe |
555-3333 |
| Sales |
Steve |
555-4444 |
| Build |
Jerry |
555-8888 |
departments/departments.json
| department |
manager |
phone |
| IT |
Bob |
555-1111 |
| Kitchen |
Jim |
555-2222 |
| Helpdesk |
Joe |
555-3333 |
| Sales |
Steve |
555-4444 |
| Build |
Jerry |
555-6666 |
departments/departments.yaml
| department |
manager |
phone |
| IT |
Bob |
555-1111 |
| Kitchen |
Jim |
555-2222 |
| Helpdesk |
Joe |
555-3333 |
| Sales |
Steve |
555-4444 |
| Build |
Jerry |
555-9999 |
|
App: check - Page: options/sort
| HTML |
RESULT |
{content 'myContent'} <table border=1> <tr> <th> volume </th> <th> edition </th> <th> file </th> </tr> @start@ <tr> <td> {$volume} </td> <td> {$edition} </td> <td> {$file} </td> </tr> @end@ </table> {/content}
{data 'myData'} [ { "volume": 55, "edition": 3, "file": "file1.xml" }, { "volume": 33, "edition": 1, "file": "file2.xml" }, { "volume": 55, "edition": 2, "file": "file11.xml" }, { "volume": 33, "edition": 3, "file": "file12.xml" }, { "volume": 55, "edition": 1, "file": "file21.xml" }, { "volume": 33, "edition": 2, "file": "file8.xml" } ] {/data}
| |
{myContent data='myData'}
|
| volume |
edition |
file |
| 55 |
3 |
file1.xml |
| 33 |
1 |
file2.xml |
| 55 |
2 |
file11.xml |
| 33 |
3 |
file12.xml |
| 55 |
1 |
file21.xml |
| 33 |
2 |
file8.xml |
|
{myContent data='myData', sort='volume;edition'}
|
| volume |
edition |
file |
| 33 |
1 |
file2.xml |
| 33 |
2 |
file8.xml |
| 33 |
3 |
file12.xml |
| 55 |
1 |
file21.xml |
| 55 |
2 |
file11.xml |
| 55 |
3 |
file1.xml |
|
{myContent data='myData', sort='volume DESC; edition DESC'}
|
| volume |
edition |
file |
| 55 |
3 |
file1.xml |
| 55 |
2 |
file11.xml |
| 55 |
1 |
file21.xml |
| 33 |
3 |
file12.xml |
| 33 |
2 |
file8.xml |
| 33 |
1 |
file2.xml |
|
{myContent data='myData', sort='file'}
|
| volume |
edition |
file |
| 55 |
3 |
file1.xml |
| 55 |
2 |
file11.xml |
| 33 |
3 |
file12.xml |
| 33 |
1 |
file2.xml |
| 55 |
1 |
file21.xml |
| 33 |
2 |
file8.xml |
|
{myContent data='myData', sort='file NATURAL'}
|
| volume |
edition |
file |
| 55 |
3 |
file1.xml |
| 33 |
1 |
file2.xml |
| 33 |
2 |
file8.xml |
| 55 |
2 |
file11.xml |
| 33 |
3 |
file12.xml |
| 55 |
1 |
file21.xml |
|
App: manual - Page: pages/3_ways_to_make_a_table
|
The @start@ / @end@ & @else@ constructs act on the number of occurences.
The {first} & {last} tags are part of the special Properties tags.
|
| HTML |
RESULT |
{data 'myArray'} [1,2,3] {/data}
| | {myArray}
<table border="1"> <tr> <td> Before the first occurrence </td> </tr> @start@ <tr> <td> For every occurence </td> </tr> @end@ <tr> <td> After the last occurrence </td> </tr> </table>
@else@
<p> No occurences at all </p>
{/myArray}
|
| Before the first occurrence |
| For every occurence |
| For every occurence |
| For every occurence |
| After the last occurrence |
| {myArray}
{first} <table border="1"> <tr> <td> Before the first occurrence </td> </tr> {/first} <tr> <td> For every occurence </td> </tr> {last} <tr> <td> After the last occurrence </td> </tr> </table> {/last}
@else@
<p> No occurences at all </p>
{/myArray}
|
| Before the first occurrence |
| For every occurence |
| For every occurence |
| For every occurence |
| After the last occurrence |
| {count 'myArray'}
<table border="1"> <tr> <td> Before the first occurrence </td> </tr> {myArray} <tr> <td> For every occurence </td> </tr> {/myArray} <tr> <td> After the last occurrence </td> </tr> </table>
@else@
<p> No occurences at all </p>
{/count}
|
| Before the first occurrence |
| For every occurence |
| For every occurence |
| For every occurence |
| After the last occurrence |
|
|
Now the same code with an empty array
The {else} construct comes active when there are zero occurences for a PAD tag.
|
| HTML |
RESULT |
{data 'myArray'} [] {/data}
| | {myArray}
<table border="1"> <tr> <td> Before the first occurrence </td> </tr> @start@ <tr> <td> For every occurence </td> </tr> @end@ <tr> <td> After the last occurrence </td> </tr> </table>
@else@
<p> No occurences at all </p>
{/myArray}
| No occurences at all | {myArray}
{first} <table border="1"> <tr> <td> Before the first occurrence </td> </tr> {/first} <tr> <td> For every occurence </td> </tr> {last} <tr> <td> After the last occurrence </td> </tr> </table> {/last}
@else@
<p> No occurences at all </p>
{/myArray}
| No occurences at all | {count 'myArray'}
<table border="1"> <tr> <td> Before the first occurrence </td> </tr> {myArray} <tr> <td> For every occurence </td> </tr> {/myArray} <tr> <td> After the last occurrence </td> </tr> </table>
@else@
<p> No occurences at all </p>
{/count}
| No occurences at all |
App: manual - Page: pages/start_end
|
The @start@ & @end@ constructs limits the occurce content of a tag to the content between those 2 constructs
|
| HTML |
RESULT |
{data 'myArray'} [1,2,3] {/data}
| | {myArray}
<table border="1"> <tr> <td> Before the first occurrence </td> </tr>
@start@ <tr> <td> For every occurence </td> </tr> @end@
<tr> <td> After the last occurrence </td> </tr> </table>
{/myArray}
|
| Before the first occurrence |
| For every occurence |
| For every occurence |
| For every occurence |
| After the last occurrence |
| {data 'myArray'} [] {/data}
| | {myArray}
<table border="1"> <tr> <td> Before the first occurrence </td> </tr> @start@ <tr> <td> For every occurence </td> </tr> @end@ <tr> <td> After the last occurrence </td> </tr> </table>
@else@
<p> No occurences at all </p>
{/myArray}
| No occurences at all |
App: manual - Page: php_and_html/z12
PHP
php_and_html/z12.php
|
HTML
php_and_html/z12.pad
|
Result
|
<?php
return [ 1 => [ 'hi' => 2 ], 2 => [ 'hi' => 3 ], 3 => [ 'hi' => 4 ] ];
?>
|
<h3>Hello World 1</h3>
@start@ <h3>Hello World {$hi}</h3> @end@
<h3>Hello World 5 </h3>
|
Hello World 1
Hello World 2
Hello World 3
Hello World 4
Hello World 5
|
App: manual - Page: php_and_html/z25
PHP
php_and_html/z25.php
|
HTML
php_and_html/z25.pad
|
Result
|
<h3>Hello World 1</h3>
<?php
$hi = 'Hello World 7';
echo '<h3>Hello World 2</h3>';
return [ 88 => [ 'hi' => 4 ], 12 => [ 'hi' => 5 ], 33 => [ 'hi' => 6 ] ];
?>
|
<h3>Hello World 3</h3>
@start@ <h3>Hello World {$hi}</h3> @end@
<h3>{$hi}</h3>
<h3>Hello World 8 </h3>
|
Hello World 1
Hello World 2Hello World 3
Hello World 4
Hello World 5
Hello World 6
Hello World 7
Hello World 8
|
App: demo - Page: todo
PHP
todo.php
|
HTML
todo.pad
|
Result
|
<?php
$title = 'Todo List'; $dataFile = DAT . 'demo/todos.json'; $message = '';
$todos = [];
if ( file_exists ( $dataFile ) ) { $json = file_get_contents ( $dataFile ); $todos = json_decode ( $json, TRUE ) ?: []; }
$hasTodos = count ( $todos ) > 0; $doneCount = count ( array_filter ( $todos, fn($t) => $t ['done'] ) ); $pendingCount = count ( $todos ) - $doneCount;
?>
|
<p>Manage your tasks with this simple todo list.</p>
{if $message} <div class="message">{$message}</div> {/if}
<h2>Add New Task</h2>
{todo 'add', 'Add Task'} <input type="text" name="task" placeholder="Enter a new task..." required style="flex: 1;"> {/todo}
<h2>Tasks ({$pendingCount} pending, {$doneCount} done)</h2>
{todos}
<table>
<tr> <th>Task</th> <th style="width: 120px;">Added</th> <th style="width: 5%; text-align: center;" colspan="2">Actions</th> </tr>
@start@
<tr{if $done} class="todo-item done"{/if}> <td>{$task}</td> <td style="font-size: 12px; color: #999;">{$date | substr (0, 10)}</td> <td> {if ! $done} {todo 'done', 'Done'} <input type="hidden" name="id" value="{$id}"> {/todo} {/if} </td> <td> {todo 'delete', 'Delete'} <input type="hidden" name="id" value="{$id}"> {/todo} </td> </tr>
@end@
</table>
{if $doneCount > 0} {todo 'clear', 'Clear Completed Tasks'}{/todo} {/if} @else@
<p>No tasks yet. Add one above!</p>
{/todos}
|
Manage your tasks with this simple todo list.
Add New Task
Tasks (0 pending, 0 done)
No tasks yet. Add one above!
|
App: check - Page: vars/at/7
PHP
|
HTML
vars/at/7.pad
|
Result
|
|
{bakery} <h2> {$name@current} / {$type@current} </h2>
<p> Batter: {batter optional} {$batter@current} {notLast} / {/notLast} {/batter}
{topping@current optional} <p> Topping: @start@ {$topping@topping} {notLast} / {/notLast} @end@ </p> {/topping@current} {filling@current optional} <p>Filling: @start@ {$name@*} {notLast} / {/notLast} @end@ </p> {/filling@current}
{/bakery}
|
Cake / donut
Batter:
Topping:
None
/
Glazed
/
Sugar
/
Powdered Sugar
/
Chocolate with Sprinkles
/
Chocolate
/
Maple
Raised / donut
Batter:
Topping:
None
/
Glazed
/
Sugar
/
Chocolate
/
Maple
Buttermilk / donut
Batter:
Bar / bar
Batter:
Topping:
Chocolate
/
Maple
Filling:
None
/
Custard
/
Whipped Cream
Twist / twist
Batter:
Topping:
Glazed
/
Sugar
Filled / filled
Batter:
Topping:
Glazed
/
Powdered Sugar
/
Chocolate
/
Maple
Filling:
Rasberry Jelly
/
Rasberry Jelly
/
Rasberry Jelly
/
Rasberry Jelly
|
|