NAME

MVC::Neaf::View::TT - Template toolkit-based view module for Neaf.

SYNOPSYS

# Somewhere in your app
return {
    -view => 'TT',
    -template => 'foo.tt',
    title => 'Page title',
    ....
};
# Neaf knows it's time to render foo.tt with returned data as stash
# and return result to user

# What actually happens
my $view = MVC::Neaf::View::TT->new;
my $content = $view->render( { ... } );

# And if in foo.tt
<title>[% title %]</title>

# Then in $content it becomes
<title>Page title</title>

DESCRIPTION

This module is one of core rendering engines of MVC::Neaf known under TT alias.

See also neaf view.

METHODS

new( %options )

%options may include:

  • template - default template to use.

  • preserve_dash - don't strip dashed options. Useful for debugging.

  • preload => { name => 'in-memory template' } - preload some templates. See preload() below.

  • INCLUDE_PATH => [path, ...] - will be calculated relative to the calling file, if not starts with a '/'.

Also any UPPERCASE OPTIONS will be forwarded to the backend (i.e. Template object) w/o changes.

Any extra options except those above will cause an exception.

render( \%data )

Returns a pair of values: ($content, $content_type).

Content-type defaults to text/html.

The template is determined from (1) -template in data (2) template in new(). If neither is present, empty string and "text/plain" are returned.

preload ( name => "[% in_memory_template %]", ... )

Store precompiled templates under given names.

Returns self, dies on error.

SEE ALSO

Template - the template toolkit used as backend.

LICENSE AND COPYRIGHT

This module is part of MVC::Neaf suite.

Copyright 2016-2023 Konstantin S. Uvarin khedin@cpan.org.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.