def style
@style ||= (
Hash.new{|h,k| h[k] = Hash.new}
)
end
helper_method :style
def css_for(style)
unless style.blank?
css = []
style.each do |selector, attributes|
unless attributes.blank?
guts = []
attributes.each do |key, val|
guts << "#{ key } : #{ val };"
end
unless guts.blank?
css << "#{ selector } { #{ guts.join(' ') } }"
end
end
end
unless css.empty?
css.join("\n")
end
end
end
"
...
<style>
<%= css_for(style) %>
</style>
</head>
...
"
style['#content']['width'] = '50%'
style['#content']['margin'] = 'auto'