This enables partials to add classes to the body definition, which
makes certain styling operations simpler.

Reviewed-By: Randall Hansen

Signed-off-by: Pieter van de Bruggen <[email protected]>
---
Local-branch: tickets/master/8196
 app/helpers/application_helper.rb       |    4 ++++
 app/views/layouts/application.html.haml |    7 ++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/app/helpers/application_helper.rb 
b/app/helpers/application_helper.rb
index 438eace..bf3f10f 100755
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -264,4 +264,8 @@ module ApplicationHelper
     @unique_id_counter ||= 0
     @unique_id_counter += 1
   end
+
+  def add_body_class(klass)
+    (@body_classes ||= []).push(klass).uniq!
+  end
 end
diff --git a/app/views/layouts/application.html.haml 
b/app/views/layouts/application.html.haml
index 1574cb4..040f3a3 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -16,9 +16,10 @@
     - Registry.each_callback :core, :head_extensions do |widget|
       = widget.call self
 
-  - body_classes = [ "#{controller.controller_name}_controller", 
"#{controller.controller_name}_#{controller.action_name}_action" ]
-  - body_classes << "#{controller.controller_name}_form_action" if %w[new 
create edit update].include?(controller.action_name)
-  %body{:class => body_classes}
+  - add_body_class "#{controller.controller_name}_controller"
+  - add_body_class 
"#{controller.controller_name}_#{controller.action_name}_action"
+  - add_body_class "#{controller.controller_name}_form_action" if %w[new 
create edit update].include?(controller.action_name)
+  %body{:class => @body_classes}
     #wrap
       #header
         = render 'shared/global_nav'
-- 
1.7.5.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to