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
version | $Id$
package | phing.lib

### Methods

## __construct()

    __construct()

## Clears one or several or all variables.

    clear(mixed $which) : void

### Parameters

#### $which

`mixed`

String name of var, or array of names.

## Low overhead (no output buffering) method to simply dump template to buffer.

    display(string $__template) : void

### Parameters

#### $__template

`string`

### Exceptions

`\Exception` | - if template cannot be found

## Gets value of specified var or NULL if var has not been put().

    get(string $name) : mixed

### Parameters

#### $name

`string`

Variable name to retrieve.

### Returns

`mixed`

## Get basepath to use for output file creation.

    getOutputDirectory() : string

### Returns

`string`

## Get the basepath to use for template lookups.

    getTemplatePath() : string

### Returns

`string`

## Fetches the results of a tempalte parse and either returns the string or writes results to a specified output file.

    parse(string $template, string $outputFile, boolean $append) : string

### Parameters

#### $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?

### Exceptions

`\Exception` | - if template not found.

### Returns

`string`The "parsed" template output.

## Adds a variable to the context.

    put(string $name, mixed $value)

Resulting template will have access to ${$name$} variable.

### Parameters

#### $name

`string`

#### $value

`mixed`

## Merges in passed hash to vars array.

    putAll(array $vars, boolean $recursiveMerge) : void

Given an array like:

           array(     'myvar' => 'Hello',
                   'myvar2' => 'Hello')

Resulting template will have access to $myvar and $myvar2.

### Parameters

#### $vars

`array`

#### $recursiveMerge

`boolean`

Should matching keys be recursively merged?

## Makes a copy of the value and puts it into the context.

    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.

### Parameters

#### $name

`string`

#### $value

`mixed`

## Put a variable into the context, assigning it by reference.

    putRef($name, \$value $value)

This means that if the template modifies the variable, then it will also be modified in the context.

### Parameters

#### $name

#### $value

`\$value`

## Set a basepath to use for output file creation.

    setOutputDirectory(string $v)

### Parameters

#### $v

`string`

## Set the basepath to use for template lookups.

    setTemplatePath(string $v)

### Parameters

#### $v

`string`

## This returns a "best guess" path for the given file.

    resolvePath(string $file, string $basepath) : string

### Parameters

#### $file

`string`

File name or possibly absolute path.

#### $basepath

`string`

The basepath that should be prepended if $file is not absolute.

### Returns

`string`"Best guess" path for this file.

### Properties

##

    $vars : array

##

    $initialized

##

    $outputDirectory : string

##

    $templatePath : string

##

    $old_include_path : string