Make an instance of the finder
[catagits/CatalystX-HelpText.git] / lib / CatalystX / HelpText / Finder / TemplateToolkit.pm
CommitLineData
54b1774e 1package CatalystX::HelpText::Finder::TemplateToolkit;
2use Moose;
54b1774e 3use List::MoreUtils qw/ uniq /;
4use Template;
009a8923 5use namespace::autoclean;
54b1774e 6
16a04c5b 7has template_search_dir => (
8 isa => Str,
9 is => 'ro',
10 required => 1,
11);
12
54b1774e 13sub find_helptext_keys_in_fn {
16a04c5b 14 my ($self, $fn) = @_;
54b1774e 15 my @keys = ();
16 my $t = Template->new({
16a04c5b 17 INCLUDE_PATH => [ $self->template_search_dir ],
54b1774e 18 ABSOLUTE => 1,
19 });
20 my $out;
21 $t->process($fn, { help_text => sub { push @keys, shift } }, \$out);
22 return [ uniq @keys ];
23}
24
009a8923 25__PACKAGE__->meta->make_immutable;
261;
27