PEAR Handbuch | ||
---|---|---|
Zurück | Nach vorne |
The format of placeholder is
{[0-9A-Za-z_-]+} |
{Placeholder} |
{place2_holder} |
{PLACEHOLDER1} |
{Place-Holder} |
{ Placeholder 3 } (spaces) |
{place*holder} (char isn't permitted) |
The format of a block is
<!-- BEGIN [0-9A-Za-z_-]+ --> ... block content ... <!-- END [0-9A-Za-z_-]+ --> |
The nesting of blocks is permitted, but be careful while parsing. You have to set and parse the deepest inner block first and then set and parse from inner to outer.
Beispiel 1. The template
|
Beispiel 2. The script
|
Beispiel 3. The output
|
Builds some complex regular expressions and optinally sets the file root directory. Make sure that you call this constructor if you derive your templateclass from this one.
Parameter
$root - root directory, prefix for all filenames given to the object.
Returns a block with all replacements done.
Parameter
$block - block to return, when not set the complete template will returned.
Parses the given block.
Parameter
$block - block to parse, when not set the complete template will be parsed.
$flag_recursion - can be ignored
Sets a variable value. The function can be used eighter like setVariable( "varname", "value") or with one array $variables["varname"] = "value" given setVariable($variables).
Parameter
$placeholder - Name of the placeholder to substitute or a array with the placeholder as key and the data to assign as value.
$variable - when $placeholder isn't a array, the value to assign to the placeholder.
Sets the name of the current block, that is the block where variables are added.
Parameter
$block - block to set, when not given the complete template is set (shows on the placeholders outside of all block).
Returns
Boolean - false on failure, otherwise true
Preserves an empty block even if removeEmptyBlocks is true
Parameter
$block - block to preserve
Returns
Boolean - false on false, otherwise true
Clears all datafields of the object and rebuilds the internal blocklist. LoadTemplatefile() and setTemplate() automatically call this function when a new template is given. Don't use this function unless you know what you're doing.
Clears all datafields of the object. Don't use this function unless you know what you're doing.
Sets the template. You can eighter load a template file from disk with LoadTemplatefile() or set the template manually using this function.
Parameter
$template - content
Reads a template file from the disk.
Parameter
$filename - name of the template file
$removeUnknownVariables - when true not assigned placeholders will be deleted
$removeEmptyBlocks - when true unused blocks will be removed
Returns
Boolean - false on false, otherwise true
Sets the file root. The file root gets prefixed to all filenames passed to the object.
Parameter
$root - root directory for the templates
$removeUnknownVariables - when true not assigned placeholders will be deleted
$removeEmptyBlocks - when true unused blocks will be removed
Print a certain block with all replacements done.
Parameter
$block - when not set the whole content will be printed.
Zurück | Zum Anfang | Nach vorne |
HTML Templates | Nach oben | HTML_Template_ITX |