CatalystX::Features::View::TT - Makes View::TT handle features.


CatalystX-Features documentation Contained in the CatalystX-Features distribution.

Index


Code Index:

NAME

Top

CatalystX::Features::View::TT - Makes View::TT handle features.

VERSION

Top

version 0.20

SYNOPSIS

Top

	package MyApp::View::TT;
	use base 'CatalystX::Features::View::TT';

    __PACKAGE__->config(
        TEMPLATE_EXTENSION => '.tt',
        root               => TestApp->path_to('root'),
        INCLUDE_PATH       => [ TestApp->path_to( 'root', 'src' ), ],
    );

DESCRIPTION

Top

Use this base class to make View::TT support TT in your features.

This class will modify INCLUDE_PATH, adding the /root dir of each feature in the app.

CONFIG

Top

tt_prefix

Appended to the feature /root dir.

	<CatalystX::Features>
		<simple.feature>
			tt_prefix src
			tt_prefix more
		</simple.feature>
	</CatalystX::Features>

AUTHORS

Top

	Rodrigo de Oliveira (rodrigolive), C<rodrigolive@gmail.com>

LICENSE

Top

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.


CatalystX-Features documentation Contained in the CatalystX-Features distribution.

package CatalystX::Features::View::TT;
$CatalystX::Features::View::TT::VERSION = '0.20';
use strict;
use warnings;
use base 'Catalyst::View::TT';
use Path::Class;

sub new {
    my ( $self, $app, $arguments ) = @_;

    $arguments->{INCLUDE_PATH} =
      ref $self->config->{INCLUDE_PATH} eq 'ARRAY'
      ? $self->config->{INCLUDE_PATH}
      : [];

    foreach my $feature ( $app->features->list ) {

        my $prefix = $app->features->config->{ $feature->name }->{tt_prefix} || '';

        if ( ref $prefix eq 'ARRAY' ) {
            for ( @{$prefix} ) {
                push(
                    @{ $arguments->{INCLUDE_PATH} },
                    Path::Class::dir( $feature->root, $_ )->stringify
                );
            }
        }
        else {
            push(
                @{ $arguments->{INCLUDE_PATH} },
                Path::Class::dir( $feature->root, $prefix )->stringify
            );
        }
    }

    $self->next::method( $app, $arguments );
}

1;