From: Tom Hughes Date: Fri, 3 Sep 2010 14:25:11 +0000 (+0100) Subject: Make helpers return text instead of appending to the output buffer X-Git-Tag: live~6133 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/ed54379218d21b9bd52933903e8cb504a15dfe7e Make helpers return text instead of appending to the output buffer --- diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b2ce9b003..e285215b8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -54,29 +54,29 @@ module ApplicationHelper end def if_logged_in(tag = :div, &block) - concat(content_tag(tag, capture(&block), :class => "hide_unless_logged_in")) + content_tag(tag, capture(&block), :class => "hide_unless_logged_in") end def if_not_logged_in(tag = :div, &block) - concat(content_tag(tag, capture(&block), :class => "hide_if_logged_in")) + content_tag(tag, capture(&block), :class => "hide_if_logged_in") end def if_user(user, tag = :div, &block) if user - concat(content_tag(tag, capture(&block), :class => "hidden show_if_user_#{user.id}")) + content_tag(tag, capture(&block), :class => "hidden show_if_user_#{user.id}") end end def unless_user(user, tag = :div, &block) if user - concat(content_tag(tag, capture(&block), :class => "hide_if_user_#{user.id}")) + content_tag(tag, capture(&block), :class => "hide_if_user_#{user.id}") else - concat(content_tag(tag, capture(&block))) + content_tag(tag, capture(&block)) end end def if_administrator(tag = :div, &block) - concat(content_tag(tag, capture(&block), :class => "hide_unless_administrator")) + content_tag(tag, capture(&block), :class => "hide_unless_administrator") end def describe_location(lat, lon, zoom = nil, language = nil) diff --git a/app/views/diary_entry/_diary_comment.html.erb b/app/views/diary_entry/_diary_comment.html.erb index da10c88ac..05cb80157 100644 --- a/app/views/diary_entry/_diary_comment.html.erb +++ b/app/views/diary_entry/_diary_comment.html.erb @@ -1,7 +1,7 @@ <%= user_thumbnail diary_comment.user %>

<%= raw(t('diary_entry.diary_comment.comment_from', :link_user => (link_to h(diary_comment.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_comment.user.display_name), :comment_created_at => l(diary_comment.created_at, :format => :friendly))) %>

<%= htmlize(diary_comment.body) %> -<% if_administrator(:span) do %> +<%= if_administrator(:span) do %> <%= link_to t('diary_entry.diary_comment.hide_link'), {:action => 'hidecomment', :display_name => diary_comment.diary_entry.user.display_name, :id => diary_comment.diary_entry.id, :comment => diary_comment.id}, {:confirm => t('diary_entry.diary_comment.confirm')} %> <% end %>
diff --git a/app/views/diary_entry/_diary_entry.html.erb b/app/views/diary_entry/_diary_entry.html.erb index 02100c74d..6ab7aaf48 100644 --- a/app/views/diary_entry/_diary_entry.html.erb +++ b/app/views/diary_entry/_diary_entry.html.erb @@ -19,10 +19,10 @@ | <%= link_to t('diary_entry.diary_entry.comment_count', :count => diary_entry.visible_comments.count), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'comments' %> <% end %> -<% if_user(diary_entry.user, :span) do %> +<%= if_user(diary_entry.user, :span) do %> | <%= link_to t('diary_entry.diary_entry.edit_link'), :action => 'edit', :display_name => diary_entry.user.display_name, :id => diary_entry.id %> <% end %> -<% if_administrator(:span) do %> +<%= if_administrator(:span) do %> | <%= link_to t('diary_entry.diary_entry.hide_link'), {:action => 'hide', :display_name => diary_entry.user.display_name, :id => diary_entry.id}, {:confirm => t('diary_entry.diary_entry.confirm')} %> <% end %> diff --git a/app/views/diary_entry/list.html.erb b/app/views/diary_entry/list.html.erb index a78b41a4f..03a326d16 100644 --- a/app/views/diary_entry/list.html.erb +++ b/app/views/diary_entry/list.html.erb @@ -5,11 +5,11 @@

<%= h(@title) %>

<% if @this_user %> - <% if_user(@this_user) do %> + <%= if_user(@this_user) do %> <%= link_to image_tag("new.png", :border=>0) + t('diary_entry.list.new'), {:controller => 'diary_entry', :action => 'new'}, {:title => t('diary_entry.list.new_title')} %> <% end %> <% else %> - <% if_logged_in do %> + <%= if_logged_in do %> <%= link_to image_tag("new.png", :border=>0) + t('diary_entry.list.new'), {:controller => 'diary_entry', :action => 'new'}, {:title => t('diary_entry.list.new_title')} %> <% end %> <% end %> diff --git a/app/views/diary_entry/view.html.erb b/app/views/diary_entry/view.html.erb index 2261e2568..63d43158d 100644 --- a/app/views/diary_entry/view.html.erb +++ b/app/views/diary_entry/view.html.erb @@ -8,7 +8,7 @@ <%= render :partial => 'diary_comment', :collection => @entry.visible_comments %> -<% if_logged_in(:div) do %> +<%= if_logged_in(:div) do %>

<%= t 'diary_entry.view.leave_a_comment' %>

<%= error_messages_for 'diary_comment' %> @@ -21,6 +21,6 @@ <% end %> <% end %> -<% if_not_logged_in(:div) do %> +<%= if_not_logged_in(:div) do %>

<%= t("diary_entry.view.login_to_leave_a_comment", :login_link => link_to(t("diary_entry.view.login"), :controller => 'user', :action => 'login', :referer => request.request_uri)) %>

<% end %> diff --git a/app/views/trace/list.html.erb b/app/views/trace/list.html.erb index 31ea0eb3a..2475b5ad2 100644 --- a/app/views/trace/list.html.erb +++ b/app/views/trace/list.html.erb @@ -14,7 +14,7 @@ <% if @display_name %> | <%= link_to t('trace.trace_header.see_all_traces'), :controller => 'trace', :action => 'list', :display_name => nil, :tag => nil, :page => nil %> <% end %> - <% unless_user(@target_user, :span) do %> + <%= unless_user(@target_user, :span) do %> | <%= link_to t('trace.trace_header.see_your_traces'), :action => 'mine', :tag => nil, :page => nil %> <% end %> <% end %> diff --git a/app/views/trace/view.html.erb b/app/views/trace/view.html.erb index 1f272b271..5a7c5bcc6 100644 --- a/app/views/trace/view.html.erb +++ b/app/views/trace/view.html.erb @@ -52,7 +52,7 @@

-<% if_user(@trace.user) do %> +<%= if_user(@trace.user) do %>
<%= button_to t('trace.view.edit_track'), :controller => 'trace', :action => 'edit', :id => @trace.id %>