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


    # Somewhere in your app
    return {
        -view => 'TT',
        -template => '',
        title => 'Page title',
    # Neaf knows it's time to render 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
    <title>[% title %]</title>

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


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

See also neaf view.


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.

    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.


Template - the template toolkit used as backend.


This module is part of MVC::Neaf suite.

Copyright 2016-2019 Konstantin S. Uvarin

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 for more information.