[interchange/STABLE_5_6-branch] Fix css.tag to properly output the css when using the inline <style> block

David Christensen interchange-cvs at icdevgroup.org
Thu Mar 25 04:44:14 UTC 2010

commit 93f9041cc97a94c9cca55192e46b087b2daf4754
Author: David Christensen <david at endpoint.com>
Date:   Tue Mar 23 22:46:02 2010 -0500

    Fix css.tag to properly output the css when using the inline <style> block
    css.tag attempts to write a file out to the filesystem after reading
    in the css via either variable or literal.  If the file path it
    attempts to write to is not writable, for whatever reason, instead of
    creating a <link> tag to the written file, it attempts to create a
    <style> tag containing the css.
    Currently, if it ever creates the style tag, it will never contain the
    css.  When the location is not writable, it skips the portion of code
    that reads in the actual css, either from the literal option or the
    contents of the variable.
    This patch moves the reading of the css up to a point where it can't
    be skipped, allowing both the link and style tags to be created
    Report and patch by Justin Otten <justin.lasotten at gmail.com>

 code/UserTag/css.tag |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/code/UserTag/css.tag b/code/UserTag/css.tag
index 65105d9..f6cf1da 100644
--- a/code/UserTag/css.tag
+++ b/code/UserTag/css.tag
@@ -95,6 +95,11 @@ sub {
 	$extra .= qq{ media="$opt->{media}"} if $opt->{media};
 	my $css;
+	$css = length($opt->{literal})
+				? $opt->{literal}
+				: interpolate_html($Tag->var($name));
+	$css =~ s/^\s*<style.*?>\s*//si;
+	$css =~ s:\s*</style>\s*$:\n:i;
 	WRITE: {
 		last WRITE unless $write;
@@ -113,11 +118,6 @@ sub {
 			last WRITE;
 		my $mode = $opt->{mode} ? oct($opt->{mode}) : 0644;
-		$css = length($opt->{literal})
-					? $opt->{literal}
-					: interpolate_html($Tag->var($name));
-		$css =~ s/^\s*<style.*?>\s*//si;
-		$css =~ s:\s*</style>\s*$:\n:i;
 		$success = $Tag->write_relative_file($fn, $css) && chmod($mode, $fn)
 			or logError("Error writing CSS file %s, returning in page", $fn);

More information about the interchange-cvs mailing list