An application teaches PAD new words by putting files in the right directory - no registration, no configuration. The file's name is the name in the template.
A file _tags/badge.php makes {badge} a tag. The file
reads its parameters with padTagParm ( name, default ) and returns what it
renders - a value, whose braces stay text; $padContent is template source, so
nothing built from a parameter goes there. The app: prefix names it
explicitly when another meaning of the name is in the way:
|
PHP |
HTML fragments/extending_1.pad |
Result |
|---|---|---|
|
«new» «plain» «explicit» |
<?php // _tags/badge.php
$label = padTagParm ( 'label', 'plain' );
return '«' . htmlspecialchars ( $label ) . '»';
?>
A file _functions/stars.php makes | stars a pipe. The file gets
the piped text as $value, its parameters as $parm, and returns the
answer - and it chains with everything else:
|
PHP |
HTML fragments/extending_2.pad |
Result |
|---|---|---|
|
*** well done *** *** WELL DONE *** |
A file _include/tip.pad is template, dropped in wherever its name is written
- bare, or with the include: prefix:
|
PHP |
HTML fragments/extending_3.pad |
Result |
|---|---|---|
|
Tip: the parser likes a single tag closed with a trailing slash. Tip: the parser likes a single tag closed with a trailing slash. |
Every .php file in _lib/ is included on every request, so a
page's PHP half calls what they define without an include of its own:
|
PHP fragments/extending_4.php |
HTML fragments/extending_4.pad |
Result |
|---|---|---|
|
|
hear me hear me |
| directory | a file there is |
|---|---|
_tags/ | a tag |
_functions/ | a pipe function |
_include/ | a template snippet |
_lib/ | PHP functions, included every request |
_callbacks/ | a data iteration hook - see callback |
_options/ | a tag option of your own - see options of your own |
_events/ | a hook for an error, a query, a fetch or the finished page - see event hooks |
_data/ | a data file, usable as a tag - see the data tag |
_scripts/ | a shell script, run by the script: prefix |
A subdirectory may carry any of these of its own: its pages see both, and its version of a name wins - the story of the application structure page.