Browse Source

Dynamic stylesheet tags

- build helper method for generating stylesheet tags
  - replace tags with a call to the helper
alt_logo
jimi 14 years ago
parent
commit
8ac2a8520e
  1. 8
      app/helpers/application_helper.rb
  2. 4
      app/views/layouts/application.html.haml

8
app/helpers/application_helper.rb

@ -8,4 +8,12 @@ module ApplicationHelper
'HVAC, electrical and plumbing services since 1965'
@description.nil? ? default : @description
end
def stylesheet_links
default = %w{reset grids layout}
styles = @stylesheets.nil? ? default : @stylesheets
html = styles.collect do |style|
"<link rel='stylesheet' media='screen' href='stylesheets/#{style}.css' />"
end
html.join("\n")
end
end

4
app/views/layouts/application.html.haml

@ -6,9 +6,7 @@
%meta(content='J.Infield' name='author')
%meta(name='description' content=page_description)
%meta(name='copyright' content='Copyright 2011 J.Infield, all rights reserved')
%link(rel='stylesheet' media='screen' href='stylesheets/reset.css')
%link(rel='stylesheet' media='screen' href='stylesheets/grids.css')
%link(rel='stylesheet' media='screen' href='stylesheets/layout.css')
!= stylesheet_links
%script(src='javascripts/jquery.min.js')
= yield :head
%body