more documentation
[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 /;
e5459d76 4use MooseX::Types::Moose qw/Str/;
54b1774e 5use Template;
009a8923 6use namespace::autoclean;
54b1774e 7
16a04c5b 8has template_search_dir => (
9 isa => Str,
10 is => 'ro',
11 required => 1,
12);
13
54b1774e 14sub find_helptext_keys_in_fn {
16a04c5b 15 my ($self, $fn) = @_;
54b1774e 16 my @keys = ();
17 my $t = Template->new({
16a04c5b 18 INCLUDE_PATH => [ $self->template_search_dir ],
54b1774e 19 ABSOLUTE => 1,
20 });
21 my $out;
8137c236 22 $t->process($fn, { help_text => sub { my $key = shift; push @keys, $key if ($key) } }, \$out);
54b1774e 23 return [ uniq @keys ];
24}
25
009a8923 26__PACKAGE__->meta->make_immutable;
271;
28
61d108e4 29=head1 NAME
30
31CatalystX::HelpText::Finder::TemplateToolkit
32
33=head1 SYNOPSIS
34
35 Find helptext keys parsing the templates using Template
36
37=head1 SEE ALSO
38
39=over
40
41=item L<CatalystX::HelpText>
42
43=back
44
45=head1 AUTHOR
46
47Toomas Doran, C<< t0m at state51.co.uk >>
48
49Cinxgler Mariaca Minda, C<< cinxgler at ci-info.com >>
50
51=head1 COPYRIGHT
52
53Copyright Oscar Music and Media 2011.
54
55=head1 LICENSE
56
57This sofware is free software, and is licensed under the same terms as perl itself.
58
59=cut
60