requires 'MooseX::Types';
build_requires 'Catalyst::Runtime' => '5.80015';
+build_requires 'Catalyst::View::TT' => '0.37';
build_requires 'Test::WWW::Mechanize::Catalyst';
build_requires 'Test::More' => '0.88';
--- /dev/null
+package CatalystX::HelpText::ViewRole;
+use Moose::Role;
+use Try::Tiny;
+
+requires 'expose_methods';
+
+around expose_methods => sub {
+ my ($orig, $self, @args) = @_;
+ my @m = $self->$orig(@args)->flatten;
+ [ @m, 'help_text' ];
+};
+
+sub help_text {
+ my ($self, $c, $key) = @_;
+ try {
+ return $c->model('Help')->get_help_text_for($c, $key);
+ }
+ catch {
+ $c->log->warn("Error retrieving help_text: ".$_);
+ return '';
+ };
+}
+
+1;
+
+=head1 NAME
+
+CatalystX::HelpText::ViewRole - Role to be applied to Views
+
+=head1 SYNOPSIS
+
+ package MyApp::View::HTML;
+ use Moose;
+
+ extends 'Catalyst::View::TT';
+ with 'CatalystX::HelpText::ViewRole';
+
+ ... then, in your template code ...
+
+ [% helptext('SomeHelpTopic') %]
+
+=cut
+
--- /dev/null
+package TestApp::View::HTML;
+use Moose;
+use namespace::autoclean;
+
+extends 'Catalyst::View::TT';
+
+with 'CatalystX::HelpText::ViewRole';
+
+1;
+