internal package
Foswiki::Templates
On this page:
internal package
Foswiki::Templates
Support for Skin Template directives
The following tokens are supported by this language:
%TMPL:P% | Instantiates a previously defined template |
%TMPL:DEF% | Opens a template definition |
%TMPL:END% | Closes a template definition |
%TMPL:INCLUDE% | Includes another file of templates |
ClassMethod
new ( $session )
Constructor. Creates a new template database object. - $session - session (Foswiki) object
ObjectMethod
finish()
Break circular references.
ObjectMethod
haveTemplate( $name ) → $boolean
Return true if the template exists and is loaded into the cache
ObjectMethod
expandTemplate( $params ) → $string
Expand the template specified in the parameter string using tmplP
.
Examples:
$tmpls->expandTemplate("blah"); $tmpls->expandTemplate(context="view" then="sigh" else="humph");
ObjectMethod
tmplP( $attrs ) → $string
Return value expanded text of the template, as found from looking
in the register of template definitions. The attrs can contain a template
name in _DEFAULT, and / or context
, then
and else
values.
Recursively expands any contained TMPL:P tags.
Note that it would be trivial to add template parameters to this,
simply by iterating over the other parameters (other than _DEFAULT, context,
then and else) and doing a s/// in the template for that parameter value. This
would add considerably to the power of templates.
ObjectMethod
readTemplate ( $name, %options ) → $text
Reads a template, loading the definitions therein.
Return value: expanded template text
By default throws an OopsException if the template was not found or the
access controls denied access.
%options include: -
skin
- skin name, -
web
- web to search -
no_oops
- if true, will not throw an exception. Instead, returns undef.