more documentation
[catagits/CatalystX-HelpText.git] / lib / CatalystX / HelpText / Finder / TemplateToolkit.pm
1 package CatalystX::HelpText::Finder::TemplateToolkit;
2 use Moose;
3 use List::MoreUtils qw/ uniq /;
4 use MooseX::Types::Moose qw/Str/;
5 use Template;
6 use namespace::autoclean;
7
8 has template_search_dir => (
9     isa => Str,
10     is => 'ro',
11     required => 1,
12 );
13
14 sub find_helptext_keys_in_fn {
15     my ($self, $fn) = @_;
16     my @keys = ();
17     my $t = Template->new({
18         INCLUDE_PATH => [ $self->template_search_dir ],
19         ABSOLUTE => 1,
20     });
21     my $out;
22     $t->process($fn, { help_text => sub { my $key = shift; push @keys, $key if ($key) } }, \$out);
23     return [ uniq @keys ];
24 }
25
26 __PACKAGE__->meta->make_immutable;
27 1;
28
29 =head1 NAME
30
31 CatalystX::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
47 Toomas Doran, C<< t0m at state51.co.uk >>
48
49 Cinxgler Mariaca Minda, C<< cinxgler at ci-info.com >>
50
51 =head1 COPYRIGHT
52
53 Copyright Oscar Music and Media 2011.
54
55 =head1 LICENSE
56
57 This sofware is free software, and is licensed under the same terms as perl itself.
58
59 =cut
60