Do not crash when passing undef to literal
[plack-app-gruntmaster.git] / lib / Plack / App / Gruntmaster / HTML.pm
index ebbc145e22cd3bd9f328c3e3a8da27b749d9e9c8..9f6f2ec5b27c6454686be8a1916a3b95df8b018e 100644 (file)
@@ -10,7 +10,14 @@ use POSIX qw//;
 use Data::Dumper qw/Dumper/;
 
 sub ftime ($)   { POSIX::strftime '%c', localtime shift }
-sub literal ($) { HTML::Element::Library::super_literal shift // '' }
+sub literal ($) {
+       my ($html) = @_;
+       return unless $html;
+       my $b = HTML::TreeBuilder->new;
+       $b->ignore_unknown(0);
+       $b->parse($html);
+       HTML::Element::Library::super_literal $b->guts->as_HTML;
+}
 
 sub HTML::Element::edit_href {
        my ($self, $sub) = @_;
This page took 0.00953 seconds and 4 git commands to generate.