Class Horde_Template

Description

Horde Template system. Adapted from bTemplate by Brian Lozier
.

Horde_Template provides a basic template engine with tags, loops, and if conditions. However, it is also a simple interface with several essential functions: set(), fetch(), and parse(). Subclasses or decorators can implement (or delegate) these three methods, plus the options api, and easily implement other template engines (PHP code, XSLT, etc.) without requiring usage changes.

$Horde: framework/Template/Template.php,v 1.38.10.15 2009/01/06 15:23:41 jan Exp $

Copyright 2002-2009 The Horde Project (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.

Located in /Template/Template.php (line 25)


	
			
Variable Summary
 array $_arrays
 string $_basepath
 array $_carrays
 array $_ifs
 array $_options
 array $_scalars
 string $_template
Method Summary
 Horde_Template Horde_Template ([string $basepath = null])
 string fetch (string $filename)
 mixed get (string $tag)
 mixed getOption (string $option)
 string parse ([string $contents = null])
 void set (string|array $tag, mixed $var, [boolean $isIf = false])
 void setCloop (string $tag, array $array, array $cases)
 void setOption (string $option, mixed $val)
 void setTemplate (string $template)
 string _parseGettext (string $contents)
Variables
array $_arrays = array() (line 53)

Loop tag values.

string $_basepath = '' (line 39)

Directory that templates should be read from.

array $_carrays = array() (line 60)

Cloop tag values.

array $_ifs = array() (line 67)

If tag values.

array $_options = array() (line 32)

Option values.

array $_scalars = array() (line 46)

Tag (scalar) values.

string $_template = null (line 81)

Cached source of template file.

string $_templateFile = null (line 74)

Name of cached template file.

Methods
Constructor Horde_Template (line 89)

Constructor. Can set the template base path and whether or not to drop template variables after a parsing a template.

Horde_Template Horde_Template ([string $basepath = null])
  • string $basepath: The directory where templates are read from.
fetch (line 206)

Fetches a template from the specified file and return the parsed contents.

  • return: The parsed template.
string fetch (string $filename)
  • string $filename: The file to fetch the template from.
get (line 187)

Returns the value of a tag or loop.

  • return: The tag value or null if the tag hasn't been set yet.
mixed get (string $tag)
  • string $tag: The tag name.
getOption (line 125)

Returns an option's value.

  • return: The option's value.
mixed getOption (string $option)
  • string $option: The option name.
parse (line 224)

Parses all variables/tags in the template.

  • return: The parsed template.
string parse ([string $contents = null])
  • string $contents: The unparsed template.
set (line 138)

Sets a tag, loop, or if variable.

void set (string|array $tag, mixed $var, [boolean $isIf = false])
  • string|array $tag: Either the tag name or a hash with tag names as keys and tag values as values.
  • mixed $var: The value to replace the tag with.
  • boolean $isIf: Is this for an <if:> tag? (Default: no).
setCloop (line 172)

Sets values for a cloop.

void setCloop (string $tag, array $array, array $cases)
  • string $tag: The name of the cloop.
  • array $array: The values for the cloop.
  • array $cases: The cases (test values) for the cloops.
setOption (line 102)

Sets an option.

void setOption (string $option, mixed $val)
  • string $option: The option name.
  • mixed $val: The option's value.
setTemplate (line 112)

Set the template contents to a string.

void setTemplate (string $template)
  • string $template: The template text.
_parseGettext (line 332)

Parses gettext tags.

  • return: The parsed contents of the gettext blocks.
string _parseGettext (string $contents)
  • string $contents: The unparsed content of the file.

Documentation generated on Sun, 30 Jan 2011 05:22:39 +0000 by phpDocumentor 1.4.3