From df611653ea27974595994d6943efec1c01c6da44 Mon Sep 17 00:00:00 2001 From: Patrick Donelan Date: Thu, 16 Jul 2009 00:21:53 +0000 Subject: [PATCH] Made FilePump work for Print CSS too. Factored out the functions that generate the \n|, $file->stringify; + return scriptTag($session, $file->stringify, $extras); } elsif ($type eq 'css') { my $file = $uploadsUrl->file($dir, $bundle->bundleUrl . '.css'); - return sprintf qq|\n|, $file->stringify; + return linkTag($session, $file->stringify, $extras); } else { return ''; @@ -108,14 +114,12 @@ sub process { } ##Admin/Design mode else { - my $template; my $files; if ($type eq 'js' || $type eq 'javascript') { - $template = qq|\n|; + $type = 'js'; $files = $bundle->get('jsFiles'); } elsif ($type eq 'css') { - $template = qq|\n|; $files = $bundle->get('cssFiles'); } else { @@ -147,13 +151,54 @@ sub process { $url = $uri->as_string; } $url =~ tr{/}{/}s; - $output .= sprintf $template, $url; + $output .= $type eq 'js' ? scriptTag($session, $url, $extras) : linkTag($session, $url, $extras); } return $output; } return ''; } +=head2 scriptTag(url, extras) + +Returns a HTML 4.01 Strict script tag + +=head3 url + +The url to use as the src attribute of the script tag + +=head3 extras (optional) + +Extra attributes to include in the script tag + +=cut + +sub scriptTag { + my ($session, $url, $extras) = @_; + my $template = qq|\n|; + return sprintf $template, $url; +} + +=head2 linkTag(url, extras) + +Returns a HTML 4.01 Strict link tag + +=head3 url + +The url to use as the href attribute of the link tag + +=head3 extras (optional) + +Extra attributes to include in the link tag. For instance, you can use this to set media="print" +on your print CSS tag. + +=cut + +sub linkTag { + my ($session, $url, $extras) = @_; + my $template = qq|\n|; + return sprintf $template, $url; +} + 1; #vim:ft=perl