[interchange/STABLE_5_4-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:07 UTC 2010

commit cc52a2fd492aeddae72a72e5664e20231cd01f52
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 d00c238..a0ad2a0 100644
--- a/code/UserTag/css.tag
+++ b/code/UserTag/css.tag
@@ -97,6 +97,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;
@@ -115,11 +120,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