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

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

__PACKAGE__->meta->make_immutable;
1;

