classes/phing/lib/Capsule.php
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.
- author
- Hans Lellelid
- package
- phing.lib
- version
- $Revision: 557 $
\Capsule
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.
- author
- Hans Lellelid
- package
- phing.lib
- version
- $Revision: 557 $
Properties

string
$outputDirectory= ''
Where should output files be written? (This is named inconsistently to be compatible w/ Texen.)
- Type
- string
Methods

clear(
mixed $which
=
null
)
:
void| Name | Type | Description |
|---|---|---|
| $which | mixed | String name of var, or array of names. |

display(
string $__template
)
:
void| Name | Type | Description |
|---|---|---|
| $__template | string |
- throws
- - if template cannot be found

get(
string $name
)
:
mixed| Name | Type | Description |
|---|---|---|
| $name | string | Variable name to retrieve. |
| Type | Description |
|---|---|
| mixed |

getOutputDirectory(
)
:
string| Type | Description |
|---|---|
| string |

getTemplatePath(
)
:
string| Type | Description |
|---|---|
| string |

parse(
string $template, string $outputFile
=
null, boolean $append
=
false
)
:
string| Name | Type | Description |
|---|---|---|
| $template | string | The template filename (relative to templatePath or absolute). |
| $outputFile | string | If specified, contents of template will also be written to this file. |
| $append | boolean | Should output be appended to source file? |
| Type | Description |
|---|---|
| string |
- throws
- - if template not found.

put(
string $name, mixed $value
)
:
Resulting template will have access to ${$name$} variable.
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $value | mixed |

putAll(
array $vars, boolean $recursiveMerge
=
false
)
:
voidGiven an array like:
array( 'myvar' => 'Hello',
'myvar2' => 'Hello')
Resulting template will have access to $myvar and $myvar2.
| Name | Type | Description |
|---|---|---|
| $vars | array | |
| $recursiveMerge | boolean | Should matching keys be recursively merged? |

putCopy(
string $name, mixed $value
)
:
This is primarily to force copying (cloning) of objects, rather than the default behavior which is to assign them by reference.
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $value | mixed |

putRef(
$name, $value
)
:
This means that if the template modifies the variable, then it will also be modified in the context.
| Name | Type | Description |
|---|---|---|
| $name | ||
| $value | &$value |

resolvePath(
string $file, string $basepath
)
:
string| Name | Type | Description |
|---|---|---|
| $file | string | File name or possibly absolute path. |
| $basepath | string | The basepath that should be prepended if $file is not absolute. |
| Type | Description |
|---|---|
| string |

setOutputDirectory(
string $v
)
:
| Name | Type | Description |
|---|---|---|
| $v | string |