From: Cinxgler Mariaca Minda Date: Tue, 27 Sep 2011 17:58:41 +0000 (+0100) Subject: added wrapper tag X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=69ca94ae51b8f87c9c8d600c324686ad35b13883;hp=47227b17d5b3ac2d9d044e298cde56d05c4510a0;p=catagits%2FCatalystX-HelpText.git added wrapper tag --- diff --git a/lib/CatalystX/HelpText.pm b/lib/CatalystX/HelpText.pm index e2b30a2..f1357cb 100644 --- a/lib/CatalystX/HelpText.pm +++ b/lib/CatalystX/HelpText.pm @@ -21,7 +21,9 @@ Create a model class in your Catalyst project like: Configure it setting value for: - help_files_path: where the help files will be found - - help_files_ext: what is the extension for the help files (default html) + - help_files_ext: what is the extension for the help files (default: html) + - wrapper_tag: what tag will be used to wrap the shippet (default: span) + - wrapper_css_class: what css class will be applied to the wrapper tag (default: help_text) Create files with the text/html to be included and store them at help_files_path. diff --git a/lib/CatalystX/HelpText/Model.pm b/lib/CatalystX/HelpText/Model.pm index 2ed4adc..8a36e7c 100644 --- a/lib/CatalystX/HelpText/Model.pm +++ b/lib/CatalystX/HelpText/Model.pm @@ -24,6 +24,19 @@ has help_files_ext => ( default => 'html', ); +has wrapper_css_class => ( + is => 'ro', + isa => Str, + default => 'help_text', +); + +has wrapper_tag => ( + is => 'ro', + isa => Str, + default => 'span', +); + + sub get_help_text_for { my ($self, $help_key) = @_; confess('No $help_key provided') unless $help_key; @@ -33,7 +46,14 @@ sub get_help_text_for { my $file = $self->_get_file($fn); - return $file->slurp if ( -e $file ); + if ( -e $file ) { + return sprintf('<%s class="%s">%s', + $self->wrapper_tag, + $self->wrapper_css_class, + $file->slurp, + $self->wrapper_tag + ); + } croak "Cannot find help text '$help_key' in $file"; } diff --git a/t/live-test.t b/t/live-test.t index f4f905c..c5a7da9 100644 --- a/t/live-test.t +++ b/t/live-test.t @@ -15,6 +15,6 @@ use ok 'TestApp'; use Test::WWW::Mechanize::Catalyst 'TestApp'; my $mech = Test::WWW::Mechanize::Catalyst->new; $mech->get_ok('http://localhost/', 'get main page'); -$mech->content_like(qr/fnarblarghfnee/i, 'see if it has our text'); +$mech->content_like(qr/fnarblargh<\/span>fnee/i, 'see if it has our text'); done_testing;