package CatalystX::HelpText::Finder::TemplateToolkit;
use Moose;
use List::MoreUtils qw/ uniq /;
use MooseX::Types::Moose qw/Str/;
use Template;
use namespace::autoclean;

has template_search_dir => (
    isa => Str,
    is => 'ro',
    required => 1,
);

sub find_helptext_keys_in_fn {
    my ($self, $fn) = @_;
    my @keys = ();
    my $t = Template->new({
        INCLUDE_PATH => [ $self->template_search_dir ],
        ABSOLUTE => 1,
    });
    my $out;
    $t->process($fn, { help_text => sub { my $key = shift; push @keys, $key if ($key) } }, \$out);
    return [ uniq @keys ];
}

__PACKAGE__->meta->make_immutable;
1;

=head1 NAME

CatalystX::HelpText::Finder::TemplateToolkit

=head1 SYNOPSIS

    Find helptext keys parsing the templates using Template

=head1 SEE ALSO

=over

=item L<CatalystX::HelpText>

=back

=head1 AUTHOR

Toomas Doran, C<< t0m at state51.co.uk >>

Cinxgler Mariaca Minda, C<< cinxgler at ci-info.com >>

=head1 COPYRIGHT

Copyright Oscar Music and Media 2011.

=head1 LICENSE

This sofware is free software, and is licensed under the same terms as perl itself.

=cut

