patTemplate
patTemplate
powerful templating engine
Located in /pattemplate/patTemplate.php (line 69)
patTemplate
Class | Description |
---|---|
JTemplate | Template class, provides an easy interface to parse and display a template file |
patTemplate_Compiler | Compiler for patTemplate |
'appName' => 'patTemplate',
'appVersion' => '3.1.0',
'author' => array(
'Stephan Schmidt <[email protected]>'
)) (line 75)
standard system vars that identify pat tools
Create a new patTemplate instance.
The constructor accepts the type of the templates as sole parameter. You may choose one of:
- html (default)
- tex
- string $type: type (either html or tex)
Adds a global variable
Global variables are valid in all templates of this object. A global variable has to be scalar, it will be converted to a string.
- string $varname: name of the global variable
- string $value: value of the variable
Adds several global variables
Global variables are valid in all templates of this object.
$variables is an associative array, containing name/value pairs of the variables.
- array $variables: array containing the variables
- string $prefix: prefix for variable names
add a directory where patTemplate should search for modules.
You may either pass a string or an array of directories.
patTemplate will be searching for a module in the same order you added them. If the module cannot be found in the custom folders, it will look in patTemplate/$moduleType.
- string $moduleType: module type
- string|array $dir: directory or directories to search.
Adds an object to a template
All properties of the object will be available as template variables.
- string $template: name of the template
- object|array $object: object or array of objects
- string $prefix: prefix for all variable names
- boolean $ignorePrivate: ignore private properties (starting with _)
Adds several rows of variables to a template
Each Template can have an unlimited amount of its own variables Can be used to add a database result as variables to a template
- string $template: name of the template
- array $rows: array containing assotiative arrays with variable/value pairs
- string $prefix: prefix for all variable names
add a variable to a template
A variable may also be an indexed array, but _not_ an associative array!
- string $template: name of the template
- string $varname: name of the variable
- mixed $value: value of the variable
Adds several variables to a template
Each Template can have an unlimited amount of its own variables $variables has to be an assotiative array containing variable/value pairs
- string $template: name of the template
- array $variables: assotiative array of the variables
- string $prefix: prefix for all variable names
enable an input filter
input filters are used to modify the template stream before it is split into smaller templates-
- string $filter: name of the input filter
- array $params: parameters for the input filter
apply input filters that have been set
This is being called by the readers.
- string $template: template
enable an output filter
Output filters are used to modify the template result before it is sent to the browser.
They are applied, when displayParsedTemplate() is called.
- string $filter: name of the output filter
- array $params: parameters for the output filter
- $template
Clears an attribute of a template
supported attributes: visibilty, loop, parse, unusedvars
- string $template: name of the template
- string $attribute: name of the attribute
Clears a global variable
- string $varname: name of the global variable
clears a parsed Template
Parsed Content, variables and the loop attribute are cleared
If you will not be using this template anymore, then you should call freeTemplate()
- string $name: name of the template
- boolean $recursive: set this to true to clear all child templates, too
clear the value of a variable
- string $template: name of the template
- string $varname: name of the variable
Clear all variables in a template
This clears only variables, but does
- string $template: name of the template
displays a parsed Template
If the template has not been loaded, it will be loaded.
- string $name: name of the template
- boolean $applyFilters: whether to apply output filters
- patTemplate_Compiler::displayParsedTemplate() : display the compiled template
Displays useful information about all or named templates
This method breaks BC, as it now awaits an array instead of unlimited parameters.
- mixed $restrict: array of templates that should be dumped, or null if you want all templates to be dumped
- string $dumper: dumper
checks wether a template exists
- string $name: name of the template
frees all templates
All memory consumed by the templates will be freed.
frees a template
All memory consumed by the template will be freed.
- string $name: name of the template
- boolean $recursive: clear dependencies of the template
Gets an attribute of a template
supported attributes: visibilty, loop, parse, unusedvars
- string $template: name of the template
- string $attribute: name of the attribute
Get all attributes of a template
- string $template: name of the template
returns a parsed Template
If the template already has been parsed, it just returns the parsed template. If the template has not been loaded, it will be loaded.
- string $name: name of the template
- boolean $applyFilters: whether to apply output filters
gets name of root base for the templates
- $reader
get the value of a variable
- string $template: name of the template
- string $varname: name of the variable
loads a patTemplate module
Modules are located in the patTemplate folder and include:
- Readers
- Caches
- Variable Modifiers
- Filters
- Functions
- Stats
- string $moduleType: moduleType (Reader|TemplateCache|Modifier|OutputFilter|InputFilter)
- string $moduleName: moduleName
- array $params: parameters for the module
- $new
load a template that had autoload="off"
This is needed, if you change the source of a template and want to load it, after changing the attribute.
- string $template: template name
open any input and load content into template
- string $input: name of the input (filename, shm segment, etc.)
- string $reader: driver that is used as reader
- string $options: name of the template that should be used as a container,
- $parseInto
checks whether a module exists.
Modules are located in the patTemplate folder and include:
- Readers
- Caches
- Variable Modifiers
- Filters
- Functions
- Stats
- string $moduleType: moduleType (Reader|TemplateCache|Modifier|OutputFilter|InputFilter)
- string $moduleName: moduleName
parse a template and push the result into a variable of any other template
If the template already has been parsed, it will just be pushed into the variable. If the template has not been loaded, it will be loaded.
- string $srcTmpl: name of the template
- boolean $destTmpl: if set to true, the value will be appended to the value already stored.
- $var
- $append
parses a template
Parses a template and stores the parsed content. mode can be "w" for write (delete already parsed content) or "a" for append (appends the new parsed content to the already parsed content)
- string $template: name of the template
- string $mode: mode for the parsing
checks, whether a placeholder exists in a template
- string $placeholder: name of the placeholder
- string $tmpl: name of the template
- boolean $cached: whether to use the cached result of a previous call
Prepare a template
This can be used if you want to add variables to a template, that has not been loaded yet.
- string $name: template name
open a file and parse for patTemplate tags
- name $filename: of the file
open any input and parse for patTemplate tags
- string $input: name of the input (filename, shm segment, etc.)
- string $reader: driver that is used as reader, you may also pass a Reader object
- array $options: additional options that will only be used for this template
- string $parseInto: name of the template that should be used as a container, should not be used by public calls.
Sets an attribute of a template
supported attributes: visibilty, loop, parse, unusedvars
- string $template: name of the template
- string $attribute: name of the attribute
- mixed $value: value of the attribute
Sets several attribute of a template
$attributes has to be a assotiative arrays containing attribute/value pairs supported attributes: visibilty, loop, parse, unusedvars
- string $template: name of the template
- array $attributes: attribute/value pairs
sets name of directory where templates are stored
- string $basedir: dir where templates are stored
set default attribute
- string $name: attribute name
- mixed $value: attribute value
set default attributes
- array $attributes: attributes
sets namespace of patTemplate tags
If you want to use more than one namespace, you may set this to an array. All tags in these namespaces will be treated as patTemplate tags.
- string|array $ns: namespace(s)
sets an option
Currently, the following options are supported
- maintainBc (true|false)
- namespace (string)
- string $option: option to set
- string $value: value of the option
sets root base for the template
The parameter depends on the reader you are using.
- string $root: root base of the templates
- $reader
set the start and end tag for variables
- string $startTag: start tag
- string $endTag: end tag
set the type for the templates
- string $type: type (html or tex)
enable a template cache
A template cache will improve performace, as the templates do not have to be read on each request.
- string $cache: name of the template cache
- array $params: parameters for the template cache
Documentation generated on Mon, 05 Mar 2007 21:16:22 +0000 by phpDocumentor 1.3.1