XML::Toolkit::Builder::ClassTemplate - A class to ...


XML-Toolkit documentation Contained in the XML-Toolkit distribution.

Index


Code Index:

NAME

Top

XML::Toolkit::Builder::ClassTemplate - A class to ...

VERSION

Top

This documentation refers to version 0.01.

SYNOPSIS

Top

use XML::Toolkit::Builder::ClassTemplate;

DESCRIPTION

Top

The XML::Toolkit::Builder::ClassTemplate class implements ...

SUBROUTINES / METHODS

Top

_build_template (method)

Parameters: none

Arguments: $_[0]

Insert description of method here...

render (method)

Parameters: none

Insert description of method here...

render_class (method)

Parameters: class

Insert description of method here...

DEPENDENCIES

Top

Modules used, version dependencies, core yes/no

Moose::Role

Moose

MooseX::AttributeHelpers

NOTES

Top

...

BUGS AND LIMITATIONS

Top

None known currently, please email the author if you find any.

AUTHOR

Top

Chris Prather (perigrin@domain.tld)

LICENCE

Top

Copyright 2009 by Chris Prather.

This software is free. It is licensed under the same terms as Perl itself.


XML-Toolkit documentation Contained in the XML-Toolkit distribution.

package XML::Toolkit::Builder::ClassTemplate;
use Moose::Role;
use Template;
use namespace::autoclean;

with qw(XML::Toolkit::Cmd::ClassTemplate);

has tt_config => (
    isa     => 'HashRef',
    is      => 'ro',
    lazy    => 1,
    default => sub {
        {
            OUTPUT_PATH => '.',
            EVAL_PERL   => 1,
            POST_CHOMP  => 1,
        };
    },
);

has tt => (
    isa        => 'Template',
    is         => 'ro',
    lazy_build => 1,
    handles    => [qw(error)],
);

sub _build_tt { Template->new( $_[0]->tt_config ) }

sub render {
    return join '', map { $_[0]->render_class($_) } $_[0]->classes;
}

sub render_class {
    my ( $self, $class ) = @_;
    my $output;
    $self->tt->process( \$self->template, { meta => $class }, \$output )
      || die $self->error;
    return $output;
}

1;
__END__