I did something similar a while ago. Basically what I did was
overrite stylesheet_link_tag to accept :defaults, very similar to how
javascript_include_tag does. If :defaults was passed, it would look
for an application.css as well as a #{controller.controller_name}.css
file. I suppose you could extend that to include ie*.css files.
Here's the code (it's actually looking for .rcss files, but that's a
different story)
module RcssHelper
#Overrides defulat styklesheet_link_tag to allow for a value
of :defaults, which includes application.rcss as well as
(controller_name).rcss
def stylesheet_link_tag(*sources)
options = sources.last.is_a?(Hash) ?
sources.pop.stringify_keys : { }
if sources.include?(:defaults)
sources.delete(:defaults)
sources << "application" if defined?(RAILS_ROOT) &&
File.exists?("#{RAILS_ROOT}/app/views/stylesheets/application.rcss")
sources << controller.controller_name if defined?(RAILS_ROOT)
&& File.exists?("#{RAILS_ROOT}/app/views/stylesheets/#
{controller.controller_name}.rcss")
end
sources.collect { |source|
source = stylesheet_path(source)
tag("link", { "rel" => "Stylesheet", "type" => "text/css",
"media" => "screen", "href" => source }.merge(options))
}.join("\n")
end
end
On Feb 23, 2007, at 4:51 PM, Patrick Crowley wrote:
Exactly. Here's one I whipped up recently, with support for IE6 and
IE7.
def stylesheet_include_tag
stylesheets = [ "application", "#{controller.controller_name}",
"ie7", "ie6" ]
stylesheets.collect! do |name|
if File.exist?("#{RAILS_ROOT}/public/stylesheets/#{name}.css")
case name
when "ie7"
"<!--[if IE 7]>\n" + stylesheet_link_tag(name) + "\n<!
[endif]-->"
when "ie6"
"<!--[if IE 6]>\n" + stylesheet_link_tag(name) + "\n<!
[endif]-->"
else
stylesheet_link_tag(name)
end
end
end
stylesheets.compact.join("\n")
end
-- Patrick
On Feb 23, 2007, at 4:39 PM, Chris Abad wrote:
I do something similar to segment my stylesheets.
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby