use warnings;
use strict;
package Module::Starter::Plugin::TT2;

our $VERSION = '0.125';

use Template;

=head1 NAME

Module::Starter::Plugin::TT2 - TT2 templates for Module::Starter::Template

=head1 VERSION

version 0.125


 use Module::Starter qw(

 Module::Starter->create_distro( ... );


This Module::Starter plugin is intended to be loaded after
Module::Starter::Plugin::Template.  It implements the C<renderer> and C<render>
methods, required by the Template plugin.  The methods are implemented with
Template Toolkit.

This module's distribution includes a directory, C<templates/dir>, and a file
C<templates/inline> that contain stock templates for use with the InlineStore
and DirStore plugins.  The module itself contains default templates in its data

=head1 USAGE

This module is meant to be used with the template stores in the SimpleStore
distribution (although you could certainly write your own template store).  If
you only want to use the built-in templates, you could have lines like this in
your config file (C<~/.module-starter/config>):

 author: Lord Poncemby
 email: ponce@peerage.eng
 plugins: Module::Starter::Simple Module::Starter::Plugin::Template
  Module::Starter::Plugin::ModuleStore Module::Starter::Plugin::TT2
 template_module: Module::Starter::Plugin::TT2

(Where the plugins line is one line.)  This tells Module::Starter to look for
the templates in the data section of Module::Starter::Plugin::TT2, which isn't
very interesting, since you'll end up getting the same effect as if you'd just
used Module::Starter without plugins.

To override this behavior, you'd instruct Module::Starter to look somewhere
else, either by changing the C<template_module> setting, changing the
MODULE_TEMPLATE_MODULE environment variable, or using a different template
store altogether (q.v., SimpleStore or other plugins).

=head1 METHODS

=head2 C<< renderer >>

As implemented, this method just creates a new Template Toolkit engine and
stores it in the Module::Starter object.


sub renderer {
  my ($self) = @_;
  my $conf = (eval $self->{template_parms})||{};
  my $renderer = Template->new($conf);

=head2 C<< render( $template, \%options ) >>

This method passes the given template contents and options to the TT2 renderer
and returns the resulting document.


sub render {
  my $self = shift;
  my $template = shift;
  my $options = shift;
  my $output;

  $options->{self} = $self;
  $options->{year} = $self->_thisyear;
  $self->renderer->process(\$template, $options, \$output);
  return $output;

=head1 AUTHOR

Ricardo SIGNES, C<< <> >>


Copyright 2004-2006 Ricardo SIGNES, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.



package [%module%];

use warnings;
use strict;

=head1 NAME

[%module%] - The fantastic new [%module%]!

=head1 VERSION

version 0.001


our $VERSION = '0.001';


Quick summary of what the module does.

Perhaps a little code snippet.

    use [%module%];

    my $foo = [%module%]->new;

=head1 EXPORT

A list of functions that can be exported.  You can delete this section
if you don't export anything, such as for a purely object-oriented module.


=head2 function1


sub function1 {

=head2 function2


sub function2 {

=head1 AUTHOR

[], C<< <[]> >>

=head1 BUGS

Please report any bugs or feature requests to
C<bug-[%rtname%]>, or through the web interface at
L<>.  I will be notified, and then you'll automatically be
notified of progress on your bug as I make changes.


Copyright [%year%] [], All Rights Reserved.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.


1; # End of [%module%]
use strict;
use warnings;
use ExtUtils::MakeMaker;

    NAME                => '[%main_module%]',
    AUTHOR              => '[% %] <[% %]>',
    VERSION_FROM        => '[%main_pm_file%]',
    ABSTRACT_FROM       => '[%main_pm_file%]',
    LICENSE             => 'perl',
    PL_FILES            => {},
    PREREQ_PM => {
        'Test::More' => 0,
    dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
    clean               => { FILES => '[%self.distro%]-*' },
use inc::Module::Install;

name     '[% self.distro  %]';
all_from '[% main_pm_file %]';
author   '[% %] <[% %]>';

build_requires 'Test::More';


use strict;
use warnings;
use Module::Build;

my $builder = Module::Build->new(
    module_name         => '[%main_module%]',
    license             => '[%self.license%]',
    dist_author         => '[] <[]>',
    dist_version_from   => '[%main_pm_file%]',
    requires => {
        'Test::More' => 0,
    add_to_cleanup      => [ '[%self.distro%]-*' ],

Revision history for [%self.distro%]

0.001   Date/time
        First version, released on an unsuspecting world.


The README is used to introduce the module and provide instructions on
how to install the module, any machine dependencies it may have (for
example C compilers and installed libraries) and any other information
that should be provided before the module is installed.

A README file is required for CPAN modules since CPAN extracts the README
file from a module distribution so that people browsing the archive
can use it get an idea of the modules uses. It is usually a good idea
to provide version information here so that people can decide whether
fixes for the module are worth downloading.




Put the correct copyright and licence information here.

Copyright (C) [%year%] [% %]

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
use Test::More;
eval "use Test::Pod 1.14";
plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
use Test::More;
eval "use Test::Pod::Coverage 1.04";
plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage"
    if $@;
use Test::More tests => [% modules.size %];

[% FOREACH module = modules -%]
[% END -%]

diag( "Testing [%modules.0%] $[%modules.0%]::VERSION" );
[% FOREACH file = files -%]
[% file %]
[% END -%]