Commit | Line | Data |
54b1774e |
1 | package CatalystX::HelpText::Finder::TemplateToolkit; |
2 | use Moose; |
54b1774e |
3 | use List::MoreUtils qw/ uniq /; |
e5459d76 |
4 | use MooseX::Types::Moose qw/Str/; |
54b1774e |
5 | use Template; |
009a8923 |
6 | use namespace::autoclean; |
54b1774e |
7 | |
16a04c5b |
8 | has template_search_dir => ( |
9 | isa => Str, |
10 | is => 'ro', |
11 | required => 1, |
12 | ); |
13 | |
54b1774e |
14 | sub 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; |
27 | 1; |
28 | |
61d108e4 |
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 | |