From 9589cc01ef7400e9d1ead38b77f742689866b892 Mon Sep 17 00:00:00 2001 From: Thomas Schmidt Date: Thu, 16 Dec 2010 18:12:18 +0100 Subject: [PATCH] move flash to partial --- app/views/layouts/_flash.html.erb | 46 +++++++++++++++++++++++++++++++++++++ app/views/layouts/application.rhtml | 26 ++------------------- 2 files changed, 48 insertions(+), 24 deletions(-) create mode 100644 app/views/layouts/_flash.html.erb diff --git a/app/views/layouts/_flash.html.erb b/app/views/layouts/_flash.html.erb new file mode 100644 index 0000000..72cffd7 --- /dev/null +++ b/app/views/layouts/_flash.html.erb @@ -0,0 +1,46 @@ +<% unless flash.blank? %> + +
+
+ + <% [:success, :error, :warn, :note, :notice, :info].each do |flash_type| + if (flash[flash_type] && !flash[flash_type].empty?) + case flash_type + when :error + flash_icon = "ui-icon-alert" + flash_header = 'ui-state-error' + when :warn + flash_icon = "ui-icon-alert" + flash_header = 'ui-state-error' + when :success + flash_icon = "ui-icon-info" + flash_header = 'ui-state-highlight' + when :note + flash_icon = "ui-icon-info" + flash_header = 'ui-state-highlight' + when :info + flash_icon = "ui-icon-info" + flash_header = 'ui-state-highlight' + when :notice + flash_icon = "ui-icon-info" + flash_header = 'ui-state-highlight' + end %> + + <% + body = flash[flash_type].gsub(/\n/, '
') + body = sanitize body, :tags => %w(a b p ul li br u), :attributes => %w(href title) + %> + +
+

+ + <%= body %> +

+
+ + <% end %> + <% end %> + +
+
+<% end %> diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index d38e603..2879221 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -47,30 +47,8 @@ - <% unless flash.empty? %> -
- <% if flash[:success] or flash[:note] %> -
-
-

- - <%=h flash[:success] %><%=h flash[:note] %> -

-
-
- <% end %> - - <% if flash[:warn] or flash[:error] %> -
-
-

- - <%=h flash[:warn] %><%=h flash[:error] %> -

-
-
- <% end %> -
+ <% unless flash.blank? %> + <%= render(:partial => "layouts/flash", :object => flash) %> <% end %>
-- 2.1.4