added wrapper tag
Cinxgler Mariaca Minda [Tue, 27 Sep 2011 17:58:41 +0000 (18:58 +0100)]
lib/CatalystX/HelpText.pm
lib/CatalystX/HelpText/Model.pm
t/live-test.t

index e2b30a2..f1357cb 100644 (file)
@@ -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.
 
index 2ed4adc..8a36e7c 100644 (file)
@@ -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</%s>',
+            $self->wrapper_tag,
+            $self->wrapper_css_class,
+            $file->slurp,
+            $self->wrapper_tag
+        );
+    }
 
     croak "Cannot find help text '$help_key' in $file";
 }
index f4f905c..c5a7da9 100644 (file)
@@ -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/fnar<span class="help_text">blargh<\/span>fnee/i, 'see if it has our text');
 
 done_testing;