phing-lib

# Class: Capsule Source Location: /lib/Capsule.php
### Class Overview
Capsule is a simple "template" engine that essentially provides an isolated context for PHP scripts. #### Author(s): Hans Lellelid <hans@xmpl.org> #### Version: $Revision: 557 $ | ### Variables $initialized $outputDirectory $templatePath $vars | ### Methods __construct clear display get getOutputDirectory getTemplatePath parse put putAll putCopy putRef resolvePath setOutputDirectory setTemplatePath
### Class Details [line 15] Capsule is a simple "template" engine that essentially provides an isolated context for PHP scripts. There is no special templating language, and therefore no limitations to what can be accomplished within templates. The main purpose of Capsule is to separate the business logic from display / output logic. #### Tags:
author: | Hans Lellelid <hans@xmpl.org>
version: | $Revision: 557 $
[ Top ] ### Class Variables #### $initialized = false [line 39] Has template been initialized. #### Tags:
access: | protected
Type: | mixed
[ Top ] #### $outputDirectory = [line 28] Where should output files be written? (This is named inconsistently to be compatible w/ Texen.) #### Tags:
access: | protected
Type: | string
[ Top ] #### $templatePath = [line 21] Look for templates here (if relative path provided). #### Tags:
access: | protected
Type: | string
[ Top ] #### $vars = array() [line 34] The variables that can be used by the templates. #### Tags:
var: | Hash of variables.
access: | public
Type: | array
[ Top ] ### Class Methods ### constructor __construct [line 47]
`Capsule __construct( )`
[ Top ] ### method clear [line 55]
`void clear( [mixed $which = null])`
Clears one or several or all variables. #### Parameters:
mixed | $which | String name of var, or array of names.
[ Top ] ### method display [line 107]
`void display( string $__template)`
Low overhead (no output buffering) method to simply dump template to buffer. #### Tags:
throws: | Exception - if template cannot be found
#### Parameters:
string | $__template |
[ Top ] ### method get [line 202]
`mixed get( string $name)`
Gets value of specified var or NULL if var has not been put(). #### Parameters:
string | $name | Variable name to retrieve.
[ Top ] ### method getOutputDirectory [line 95]
`string getOutputDirectory( )`
Get basepath to use for output file creation. [ Top ] ### method getTemplatePath [line 79]
`string getTemplatePath( )`
Get the basepath to use for template lookups. [ Top ] ### method parse [line 149]
`string parse( string $template, [string $outputFile = null], [boolean $append = false])`
Fetches the results of a tempalte parse and either returns the string or writes results to a specified output file. #### Tags:
return: | The "parsed" template output.
throws: | Exception - if template not found.
#### Parameters:
string | $template | The template filename (relative to templatePath or absolute).
string | $outputFile | If specified, contents of template will also be written to this file.
boolean | $append | Should output be appended to source file?
[ Top ] ### method put [line 237]
`void put( string $name, mixed $value)`
Adds a variable to the context. Resulting template will have access to ${$name$} variable. #### Parameters:
string | $name |
mixed | $value |
[ Top ] ### method putAll [line 221]
`void putAll( array $vars, [boolean $recursiveMerge = false])`
Merges in passed hash to vars array. Given an array like: array( 'myvar' => 'Hello', 'myvar2' => 'Hello') Resulting template will have access to $myvar and $myvar2. #### Parameters:
array | $vars |
boolean | $recursiveMerge | Should matching keys be recursively merged?
[ Top ] ### method putCopy [line 260]
`void putCopy( string $name, mixed $value)`
Makes a copy of the value and puts it into the context. This is primarily to force copying (cloning) of objects, rather than the default behavior which is to assign them by reference. #### Parameters:
string | $name |
mixed | $value |
[ Top ] ### method putRef [line 249]
`void putRef( $name $name, &$value &$value)`
Put a variable into the context, assigning it by reference. This means that if the template modifies the variable, then it will also be modified in the context. #### Parameters:
$name | $name |
&$value | &$value |
[ Top ] ### method resolvePath [line 186]
`string resolvePath( string $file, string $basepath)`
This returns a "best guess" path for the given file. #### Tags:
return: | "Best guess" path for this file.
access: | protected
#### Parameters:
string | $file | File name or possibly absolute path.
string | $basepath | The basepath that should be prepended if $file is not absolute.
[ Top ] ### method setOutputDirectory [line 87]
`void setOutputDirectory( string $v)`
Set a basepath to use for output file creation. #### Parameters:
string | $v |
[ Top ] ### method setTemplatePath [line 71]
`void setTemplatePath( string $v)`
Set the basepath to use for template lookups. #### Parameters:
string | $v |
[ Top ] Documentation generated on Mon, 19 Oct 2009 10:50:27 +0200 by phpDocumentor 1.4.3