NAME

Typist::Template::Context - contains and manages the context for a template

METHODS

Typist::Template::Context->new(\%init_stash);
$ctx->stash($key, $scalar)
$ctx->unstash($key)
$ctx->var($name,[$val])

Set/get and template variable.

$this->add_tag(name => \&handler_code)
$this->add_container_tag(name => \&handler_code)
$this->add_conditional_tag(name => \&handler_code)

These three methods register template tags and take the same parameters. The difference is how the build will treat them. They require parameters of the tag name and a CODE reference to the tag handler.

If $this is an object the tag's scope will be tied to that specific object rather then the Typist::Template::Context class.

add_tag registers a variable tag. These tags must use $ inside the angle brackets such as <$MTEntryTitle$> These types of tags do not have any type of contents.

add_container_tag registers a tag which can contain text or other tags. Use container tags to create loops or specific contexts.

add_conditional_tag registers a special type of container tag that renders its contents if a some condition is true. These tag handlers need only return a true or false value. The rest is handled automatically. Container tags work with the built-in Else tag to render context if a conditional does not evaulate as true.

$this->add_global_filter(filter_name => \&handler_code)

Registers a global filter handler. Requires the name of the filter and a reference to the filter handler be passed.

If $this is an object the filter's scope will be tied to that specific object rather then the Typist::Template::Context class.