App: manual Page: fragments/response_fragments_1
PHP
|
HTML
fragments/response_fragments_1.pad
|
Result
|
|
<h4>Orders</h4>
{fragment 'order-list'} <ul> {sequence '101..103', name='number'}<li>Order {$number}</li>{/sequence} </ul> {/fragment}
<p>The page goes on here.</p>
|
|
App: manual Page: fragments/stacks_1
PHP
|
HTML
fragments/stacks_1.pad
|
Result
|
|
<p>Stylesheets this page needs:</p> <ul>{stack 'styles'}</ul>
{sequence '1..3', name='n'} {push 'styles', once='badge'}<li>badge.css</li>{/push} <span class="badge">badge {$n}</span> {/sequence}
{push 'styles'}<li>footer.css</li>{/push}
|
|
App: manual Page: lvl_occ/5
PHP
|
HTML
lvl_occ/5.pad
|
Result
|
|
<table border='1'> {sequence '10..30', increment=10, name='row'} <tr> {sequence '1..5', name='column'} <td>{$row | + $column}</td> {/sequence} </tr> {/sequence} </table>
|
|
App: manual Page: pages/levels_and_occurrences
PHP
|
HTML
pages/levels_and_occurrences.pad
|
Result
|
|
<p> {block} PAD is data driven, the PAD data concepts are named Level and Occurence <br><br> Below example: <br> - Is two levels deep <br> - The level 'row' has 3 occurences<br> - The level 'column' has 5 occurences<br><br> {/block} {example 'lvl_occ/1', skipNames, center} </p>
{block} If not specifield for a PAD tag then default it has 1 occurence. <br><br><hr><br> Just for fun, below the above example implemented in a few different ways. <br> Hopefully all this magic will be explained in this manual. {/block}
<p> {sequence '2..12', name='xxx'} {example 'lvl_occ/{$xxx}', skipNames{notFirst},skipOpen,skipHeader{/notFirst}{notLast},skipClose{/notLast}} {/sequence} </p>
|
|
App: manual Page: pages/response_fragments
PHP
|
HTML
pages/response_fragments.pad
|
Result
|
|
{meta title='Response fragments'}
<p>A search result, a page of a list, a counter: a part of a page that the browser wants to refresh on its own. <code>{fragment 'name'}...{/fragment}</code> names such a part. A normal request renders the whole page, the fragment in its place:</p>
{example 'fragments/response_fragments_1'}
<p>A request that adds <code>&padFragment=order-list</code> to the URL gets that fragment and nothing else - the same template serves the full page and the update:</p>
{example 'fragments/response_fragments_2'}
<h2>How it works</h2>
<ul> <li>The page renders up to the end of the fragment, and the fragment's rendering - closing pipe included - is the whole response. What comes after it is not rendered at all.</li> <li>The response is bare, like a <code>padInclude</code> request: no wrapper, no tidy.</li> <li>The first fragment of that name to finish rendering is the one sent. Keep a fragment unconditional and put conditions inside it: a request for a fragment that never rendered is an error under the strict check, and an empty 404 otherwise.</li> <li>The page's PHP may decide too: <code>$padFragmentOnly = 'order-list';</code> - for instance when the request carries an <code>HX-Request</code> header.</li> </ul>
<h2>With ajax and HTMX</h2>
<ul> <li><code>{ajax 'orders', fragment='order-list'}</code> fetches only that fragment of the page into its div.</li> <li>HTMX: <code><div hx-get="?orders&padFragment=order-list" hx-trigger="every 5s"></code> swaps in the fresh list.</li> <li>An HTMX request needs no <code>padFragment</code> when it swaps an element named like the fragment: <code>hx-target="#order-list"</code> sends <code>HX-Target: order-list</code>, and a page with a fragment of that name answers it alone. A page without one renders whole, as it would otherwise. See {manual 'htmx'}.</li> </ul>
|
|
App: manual Page: pages/stacks
PHP
|
HTML
pages/stacks.pad
|
Result
|
|
{meta title='Stacks: push and stack'}
<p>A component knows which script or stylesheet it needs; the layout knows where those belong. <code>{push 'name'}</code> adds rendered text to a named stack where the component is used, and <code>{stack 'name'}</code> prints the stack - in the <code><head></code>, say, far above the components that fill it.</p>
{example 'fragments/stacks_1'}
<h2>Filled in at the end</h2>
<p>A page renders from top to bottom, so a <code>{stack}</code> in the head comes out before anything below it has pushed. It prints a marker instead, and the marker is replaced by the stack once the whole page has rendered: it gets every push of the page, made above it or below it, in the order they were made.</p>
<h2>once</h2>
<ul> <li><code>once='chart'</code> - the first push of that key is kept and a later one is skipped before its content renders, so a component used fifty times renders its script tag once. Keys are per stack.</li> <li><code>once</code> without a key - a push whose rendered text the stack already holds is dropped.</li> </ul>
<h2>Where pushes come from</h2>
<ul> <li>The content of a push renders where the tag stands, with the variables of that spot - inside a loop, the row's.</li> <li>A plain <code>{page}</code> or <code>{code}</code> pass adds to the page's stacks; a sandbox, clean or reset pass keeps its own.</li> <li>A push inside a <code>{cache}</code> section is stored with the section and made again on every hit.</li> <li>From PHP: <code>padStackPush ( 'scripts', $html, $once )</code>.</li> </ul>
|
|
App: regression/common Page: manual/table_fun
PHP
|
HTML
manual/table_fun.pad
|
Result
|
|
<p>10 ways to show the same table</p>
{example 'tableFun/fun_0', skipNames,skipClose} {example 'tableFun/fun_1_a', skipNames,skipOpen,skipHeader,skipClose} {example 'tableFun/fun_1_b', skipNames,skipOpen,skipHeader,skipClose} {example 'tableFun/fun_2_a', skipNames,skipOpen,skipHeader,skipClose} {example 'tableFun/fun_3_a', skipNames,skipOpen,skipHeader,skipClose} {example 'tableFun/fun_3_b', skipNames,skipOpen,skipHeader,skipClose} {example 'tableFun/fun_5_a', skipNames,skipOpen,skipHeader,skipClose} {example 'tableFun/fun_5_b', skipNames,skipOpen,skipHeader,skipClose} {example 'tableFun/fun_8', skipNames,skipOpen,skipHeader,skipClose} {example 'tableFun/fun_9', skipNames,skipOpen,skipHeader}
|
|
App: regression/common Page: tableFun/fun_5_b
PHP
|
HTML
tableFun/fun_5_b.pad
|
Result
|
|
<table border='1'> {sequence '10..30', increment=10, name='row'} <tr> {sequence '1..5', name='column'} {cell $row + $column} {/sequence} </tr> {/sequence} </table>
|
|
App: regression/errors Page: eval/the_position_build_is_no_name_to_write
PHP
|
HTML
eval/the_position_build_is_no_name_to_write.pad
|
Result
|
|
{sequence '2;3', name='n'}[{sequence eval='@*$n', build='position', rows=3}{$sequence} {/sequence}]{/sequence}
|
|
App: regression/framework Page: check/vars_at_3
PHP
|
HTML
check/vars_at_3.pad
|
Result
|
|
{sequence '25..100', name='myRange'}
{$myRange.<} <br> {$myRange.<1} <br> {$myRange.<2} <br> {$myRange.<3} <br>
{$myRange.>} <br> {$myRange.>1} <br> {$myRange.>2} <br> {$myRange.>3} <br>
{$myRange.<3} <br> {$<3@myRange} <br> {$myRange.<3@sequence} <br> {$<3@sequence:myRange} <br>
|
|
App: regression/framework Page: data/and_it_numbers_them_from_one_when_given_a_name
PHP
|
HTML
data/and_it_numbers_them_from_one_when_given_a_name.pad
|
Result
|
|
{sequence 3, name='n'} {$n}, {/sequence}
|
|
App: regression/framework Page: sequence/a_count_or_range_is_read_wherever_the_options_stand
PHP
|
HTML
sequence/a_count_or_range_is_read_wherever_the_options_stand.pad
|
Result
|
|
[{sequence name='i', 5}{$i} {/sequence}][{sequence rows=2, '1..4'}{$sequence} {/sequence}][{sequence ';5;6'}{$sequence} {/sequence}][{sequence 5, name='i'}{$i}{/sequence}][{sequence rows=3}{$sequence}{/sequence}]
|
|
App: regression/framework Page: sequence/a_list_has_no_empty_entries_and_trims_its_words
PHP
|
HTML
sequence/a_list_has_no_empty_entries_and_trims_its_words.pad
|
Result
|
|
a[{sequence '1;2;', count}{$sequence}{/sequence}] b[{sequence 'red; green', name='c'}<{$c}>{/sequence}] c[{sequence 'red;green;', last}<{$sequence}>{/sequence}] d[{sequence '1;;2'}{$sequence}|{/sequence}] e[{sequence ' 3 ; 4 '}<{$sequence}>{/sequence}]
|
|
App: regression/framework Page: sequence/a_list_the_request_or_a_row_brings_under_a_store_name_leaves_the_store_to_the_sequence
PHP
sequence/a_list_the_request_or_a_row_brings_under_a_store_name_leaves_the_store_to_the_sequence.php
|
HTML
sequence/a_list_the_request_or_a_row_brings_under_a_store_name_leaves_the_store_to_the_sequence.pad
|
Result
|
<?php
// The visitor sends ?primes[]=1&orders[]=7 - lists, under the names of the stores the page // pushes and names - which become variables as every request value does. They are no array // the page made: the stores are kept as without them, where the first ended the page on // "the store name 'primes' is already an array of the page" and the second kept no store.
$_GET ['primes'] = [ '1' ]; $_GET ['orders'] = [ '7' ];
padGetParms ( 'GET', [ 'primes' => [ '1' ], 'orders' => [ '7' ] ] );
?>
|
[{sequence '1..3', push='primes'/}{pull:primes}{$primes} {/pull:primes}] [{sequence 3, name='orders'}{$orders}{/sequence}|{pull:orders}{$orders}{/pull:orders}] {data 'o'}[{"id":1,"kids":[{"k":1}]}]{/data}[{o}{sequence '1..2', push='kids'/}{pull:kids}{$kids}{/pull:kids}{/o}]
|
|
App: regression/framework Page: sequence/a_loop_named_like_a_page_array_or_a_store_keeps_no_store_under_that_name
PHP
sequence/a_loop_named_like_a_page_array_or_a_store_keeps_no_store_under_that_name.php
|
HTML
sequence/a_loop_named_like_a_page_array_or_a_store_keeps_no_store_under_that_name.pad
|
Result
|
<?php
$orders = [ [ 'id' => 'A1' ], [ 'id' => 'B2' ] ];
?>
|
before:[{orders}{$id} {/orders}] loop:[{sequence 3, name='orders'}{$orders} {/sequence}] after:[{orders}{$id} {/orders}] {data 'x'}[{"a":7},{"a":8}]{/data}[{sequence '1..3', name='x'}{$x} {/sequence}][{x}{$a} {/x}] {content 'c'}CONTENT{/content}[{sequence 2, name='c'}{$c}{/sequence}][{c}] [{sequence 2, name='free'}{$free}{/sequence}][{free}{$free}{/free}]
|
|
|