From 8ac2a8520eff5fa8b8d4bb61cad57f99cef05aab Mon Sep 17 00:00:00 2001 From: jimi Date: Sat, 19 Feb 2011 17:45:56 -0600 Subject: [PATCH] Dynamic stylesheet tags - build helper method for generating stylesheet tags - replace tags with a call to the helper --- app/helpers/application_helper.rb | 8 ++++++++ app/views/layouts/application.html.haml | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ec706aa..d376e9e 100644 --- a/app/helpers/application_helper.rb +++ b/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| + "" + end + html.join("\n") + end end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 78265a6..9a944de 100644 --- a/app/views/layouts/application.html.haml +++ b/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