Simplify calls to render partial

We're also adding a bit of consistency, since most of our calls to
partial rendering omit the `partial` and `locals` keys.
This commit is contained in:
Javi Martín
2019-06-22 03:59:53 +02:00
parent 6923cdda89
commit 911fe4e481
42 changed files with 99 additions and 102 deletions

View File

@@ -65,9 +65,9 @@ module ImagesHelper
def render_image(image, version, show_caption = true)
version = image.persisted? ? version : :original
render partial: "images/image", locals: { image: image,
render "images/image", image: image,
version: version,
show_caption: show_caption }
show_caption: show_caption
end
def image_direct_upload_url(imageable)

View File

@@ -55,7 +55,7 @@
title: @admin_notification.title,
body: @admin_notification.body,
timestamp: Time.current } %>
<% link_text = render partial: "/notifications/notification_body", locals: locals %>
<% link_text = render "/notifications/notification_body", locals %>
<%= link_to_if @admin_notification.link.present?, link_text, @admin_notification.link %>
</li>
</ul>

View File

@@ -19,8 +19,8 @@
<% if @investments.any? %>
<h3 class="inline-block"><%= page_entries_info @investments %></h3>
<%= render partial: "admin/shared/columns_selector",
locals: { cookie: "investments-columns", default: %w[id title supports admin valuator geozone feasibility price valuation_finished visible_to_valuators selected incompatible] } %>
<%= render "admin/shared/columns_selector",
cookie: "investments-columns", default: %w[id title supports admin valuator geozone feasibility price valuation_finished visible_to_valuators selected incompatible] %>
<br>
<%= render "filters_description", i18n_namespace: "admin.budget_investments.index" %>

View File

@@ -17,7 +17,7 @@
</div>
<hr>
<%= render partial: "/budgets/investments/investment_detail", locals: {investment: @investment, preview: true} %>
<%= render "/budgets/investments/investment_detail", investment: @investment, preview: true %>
<hr>
<h2 id="classification"><%= t("admin.budget_investments.show.classification") %></h2>

View File

@@ -8,12 +8,12 @@
<h3><%= t("admin.local_census_records.imports.show.subtitle") %></h3>
<%= render partial: "local_census_records", locals: {
<%= render "local_census_records",
title: t("admin.local_census_records.imports.show.errored"),
id: "invalid-local-census-records",
local_census_records: @import.invalid_records } %>
local_census_records: @import.invalid_records %>
<%= render partial: "local_census_records", locals: {
<%= render "local_census_records",
title: t("admin.local_census_records.imports.show.created"),
id: "created-local-census-records",
local_census_records: @import.created_records } %>
local_census_records: @import.created_records %>

View File

@@ -17,7 +17,7 @@
<tbody>
<% @booths.each do |booth| %>
<tr id="<%= dom_id(booth) %>" class="booth">
<%= render partial: "booth_assignment", locals: { booth: booth, booth_assignment: booth.assignment_on_poll(@poll) } %>
<%= render "booth_assignment", booth: booth, booth_assignment: booth.assignment_on_poll(@poll) %>
</tr>
<% end %>
</tbody>

View File

@@ -20,7 +20,7 @@
</thead>
<tbody>
<% @booths.each do |booth| %>
<%= render partial: "booth", locals: { booth: booth } %>
<%= render "booth", booth: booth %>
<% end %>
</tbody>
</table>

View File

@@ -8,8 +8,8 @@
<p><%= t("admin.system_emails.#{@system_email}.preview_detail") %></p>
<% @previews.each do |preview| %>
<%= render partial: "admin/system_emails/preview_pending/#{@system_email}",
locals: { preview: preview } %>
<%= render "admin/system_emails/preview_pending/#{@system_email}",
preview: preview %>
<% end %>
</div>

View File

@@ -10,11 +10,11 @@
<tbody>
<% valuators.each do |valuator| %>
<% if valuator.is_a?(Valuator) %>
<%= render partial: 'valuator_row', locals: {valuator: valuator} %>
<%= render "valuator_row", valuator: valuator %>
<% elsif valuator.valuator? %>
<%= render partial: 'valuator_row', locals: {valuator: valuator.valuator} %>
<%= render "valuator_row", valuator: valuator.valuator %>
<% else %>
<%= render partial: 'user_row', locals: {user: valuator} %>
<%= render "user_row", user: valuator %>
<% end %>
<% end %>
</tbody>

View File

@@ -8,7 +8,7 @@
<% if @valuators.any? %>
<h3 class="margin"><%= page_entries_info @valuators %></h3>
<%= render partial: "valuators", locals: {valuators: @valuators} %>
<%= render "valuators", valuators: @valuators %>
<%= paginate @valuators %>
<% else %>

View File

@@ -5,7 +5,7 @@
<div id="valuators">
<% if @users.any? %>
<h3 class="margin"><%= page_entries_info @users %></h3>
<%= render partial: "valuators", locals: {valuators: @users} %>
<%= render "valuators", valuators: @users %>
<% else %>
<div class="callout alert margin">
<%= t("admin.shared.no_search_results") %>

View File

@@ -60,11 +60,11 @@
<div id="<%= dom_id(investment) %>_votes"
class="small-12 medium-3 column text-center"
<%= "data-equalizer-watch" if feature?(:allow_images) && investment.image.present? %>>
<%= render partial: "/budgets/investments/votes", locals: {
<%= render "/budgets/investments/votes",
investment: investment,
investment_votes: investment_votes,
vote_url: namespaced_budget_investment_vote_path(investment, value: "yes")
} %>
%>
</div>
<% elsif investment.should_show_vote_count? %>
<div id="<%= dom_id(investment) %>_votes"
@@ -81,11 +81,11 @@
<div id="<%= dom_id(investment) %>_ballot"
class="small-12 medium-3 column text-center"
<%= "data-equalizer-watch" if feature?(:allow_images) && investment.image.present? %>>
<%= render partial: "/budgets/investments/ballot", locals: {
<%= render "/budgets/investments/ballot",
investment: investment,
investment_ids: investment_ids,
ballot: ballot
} %>
%>
</div>
<% elsif investment.should_show_price? %>
<div id="<%= dom_id(investment) %>_price"

View File

@@ -18,7 +18,7 @@
<div class="small-12 medium-9 column">
<%= back_link_to budget_investments_path(investment.budget, heading_id: investment.heading) %>
<%= render partial: "/budgets/investments/investment_detail", locals: {investment: investment} %>
<%= render "/budgets/investments/investment_detail", investment: investment %>
</div>
<aside class="small-12 medium-3 column">
@@ -41,11 +41,11 @@
<h2><%= t("budgets.investments.show.supports") %></h2>
<div class="text-center">
<div id="<%= dom_id(investment) %>_votes">
<%= render partial: "/budgets/investments/votes", locals: {
<%= render "/budgets/investments/votes",
investment: investment,
investment_votes: investment_votes,
vote_url: vote_budget_investment_path(investment.budget, investment, value: "yes")
} %>
%>
</div>
</div>
<% elsif investment.should_show_vote_count? %>
@@ -64,11 +64,10 @@
<h2><%= t("budgets.investments.show.votes") %></h2>
<div class="text-center">
<div id="<%= dom_id(investment) %>_ballot">
<%= render partial: "ballot", locals: {
<%= render "ballot",
investment: investment,
investment_ids: investment_ids,
ballot: ballot,
} %>
ballot: ballot %>
</div>
</div>
<% end %>

View File

@@ -45,13 +45,13 @@
<% if user_voted_for && setting["twitter_handle"] %>
<div class="share-supported">
<%= render partial: "shared/social_share", locals: {
<%= render "shared/social_share",
title: investment.title,
image_url: image_absolute_url(investment.image, :thumb),
url: budget_investment_url(investment.budget, investment),
description: investment.title,
mobile: investment.title
} %>
%>
</div>
<% end %>
</div>

View File

@@ -73,19 +73,17 @@
<% if investments_default_view? %>
<% @investments.each do |investment| %>
<%= render partial: "/budgets/investments/investment",
locals: {
<%= render "/budgets/investments/investment",
investment: investment,
investment_ids: @investment_ids,
investment_votes: @investment_votes,
ballot: @ballot
} %>
ballot: @ballot %>
<% end %>
<% else %>
<% @investments.each do |investment| %>
<%= render partial: "/budgets/investments/investment_minimal",
locals: { investment: investment } %>
<%= render "/budgets/investments/investment_minimal",
investment: investment %>
<% end %>
<% end %>

View File

@@ -3,12 +3,12 @@
<%= render "shared/canonical", href: budget_investment_url %>
<% end %>
<%= render partial: "/budgets/investments/investment_show", locals: {
<%= render "/budgets/investments/investment_show",
investment: @investment,
investment_ids: @investment_ids,
investment_votes: @investment_votes,
ballot: @ballot
} %>
%>
<div class="row">
<div class="small-12 column">
@@ -18,9 +18,9 @@
<div class="tabs-content" data-tabs-content="investments_tabs">
<div class="tabs-panel is-active" id="tab-comments">
<%= render partial: "/comments/comment_tree", locals: { comment_tree: @comment_tree,
<%= render "/comments/comment_tree", comment_tree: @comment_tree,
comment_flags: @comment_flags,
display_comments_count: false } %>
display_comments_count: false %>
</div>
<%= render "milestones/milestones", milestoneable: @investment %>

View File

@@ -32,10 +32,10 @@
<div class="text-center">
<h3><%= t("dashboard.mailer.forward.share_in") %></h3>
<%= render partial: 'shared/social_share', locals: {
<%= render "shared/social_share",
title: @proposal.title,
url: proposal_url(@proposal),
description: @proposal.summary } %>
description: @proposal.summary %>
</div>
</div>
</div>

View File

@@ -71,7 +71,7 @@
<%= render @debates %>
<% else %>
<% @debates.each do |debate| %>
<%= render partial: "debates/debate_minimal", locals: { debate: debate } %>
<%= render "debates/debate_minimal", debate: debate %>
<% end %>
<% end %>
<% else %>

View File

@@ -56,13 +56,13 @@
<div id="<%= dom_id(@debate) %>_votes">
<%= render "debates/votes", debate: @debate %>
</div>
<%= render partial: "shared/social_share", locals: {
<%= render "shared/social_share",
share_title: t("debates.show.share"),
title: @debate.title,
url: debate_url(@debate),
description: @debate.title,
mobile: @debate.title
} %>
%>
</aside>
</div>
</div>

View File

@@ -22,7 +22,7 @@
<h1 class="show-for-sr"><%= setting["org_name"] %></h1>
<div class="wrapper <%= yield (:wrapper_class) %>">
<%= render partial: "layouts/header", locals: { with_subnavigation: true } %>
<%= render "layouts/header", with_subnavigation: true %>
<!--[if lt IE 9]>
<% if browser.ie? && cookies["ie_alert_closed"] != "true" %>

View File

@@ -33,13 +33,13 @@
<div class="off-canvas position-left" id="offCanvas" data-off-canvas>
<div class="show-for-small-only">
<div class="dashboard-sidebar" data-equalizer-watch>
<%= render partial: "dashboard/menu" %>
<%= render "dashboard/menu" %>
</div>
</div>
</div>
<div class="off-canvas-content" data-off-canvas-content>
<%= render partial: 'layouts/header', locals: {with_subnavigation: false} %>
<%= render "layouts/header", with_subnavigation: false %>
<div class="no-margin-top row expanded collapse" data-equalizer>
<div class="small-12 medium-3 column" data-equalizer-watch>
@@ -52,14 +52,14 @@
<div id="side_menu" class="hide-for-small-only">
<div class="dashboard-sidebar" data-equalizer-watch>
<%= render partial: "dashboard/menu" %>
<%= render "dashboard/menu" %>
</div>
</div>
</div>
<div class="admin-content small-12 medium-9 column" data-equalizer-watch>
<%= render partial: "layouts/flash" %>
<%= render partial: "layouts/dashboard/proposal_totals" %>
<%= render partial: "layouts/dashboard/proposal_header" %>
<%= render "layouts/flash" %>
<%= render "layouts/dashboard/proposal_totals" %>
<%= render "layouts/dashboard/proposal_header" %>
<%= yield %>
</div>
</div>

View File

@@ -33,13 +33,13 @@
<div class="off-canvas position-left" id="offCanvas" data-off-canvas>
<div class="show-for-small-only">
<div class="dashboard-sidebar" data-equalizer-watch>
<%= render partial: 'proposals_dashboard/menu' %>
<%= render "proposals_dashboard/menu" %>
</div>
</div>
</div>
<div class="off-canvas-content" data-off-canvas-content>
<%= render partial: 'layouts/header', locals: {with_subnavigation: false} %>
<%= render "layouts/header", with_subnavigation: false %>
<div class="no-margin-top row expanded collapse" data-equalizer>
<div class="small-12 medium-3 column" data-equalizer-watch>
@@ -52,14 +52,14 @@
<div id="side_menu" class="hide-for-small-only">
<div class="dashboard-sidebar" data-equalizer-watch>
<%= render partial: 'proposals_dashboard/menu' %>
<%= render "proposals_dashboard/menu" %>
</div>
</div>
</div>
<div class="admin-content small-12 medium-9 column" data-equalizer-watch>
<%= render partial: 'layouts/flash' %>
<%= render partial: 'layouts/dashboard/proposal_totals' %>
<%= render partial: 'layouts/dashboard/proposal_header' %>
<%= render "layouts/flash" %>
<%= render "layouts/dashboard/proposal_totals" %>
<%= render "layouts/dashboard/proposal_header" %>
<%= yield %>
</div>
</div>

View File

@@ -42,9 +42,9 @@
</aside>
</div>
<%= render partial: "/comments/comment_tree", locals: { comment_tree: @comment_tree,
<%= render "/comments/comment_tree", comment_tree: @comment_tree,
comment_flags: @comment_flags,
display_comments_count: true } %>
display_comments_count: true %>
</div>
</div>
</div>

View File

@@ -36,13 +36,13 @@
</div>
<aside class="small-12 medium-3 column">
<%= render partial: "shared/social_share", locals: {
<%= render "shared/social_share",
share_title: t("proposals.show.share"),
title: @process.title,
url: legislation_process_url(@process),
description: @process.title,
mobile: @process.title
} %>
%>
<% if @process.image.present? %>
<hr>

View File

@@ -37,12 +37,12 @@
<% if voted_for?(@featured_proposals_votes, proposal) %>
<% if setting["twitter_handle"] %>
<div class="share-supported">
<%= render partial: "shared/social_share", locals: {
<%= render "shared/social_share",
title: proposal.title,
url: proposal_url(proposal),
description: proposal.summary,
mobile: proposal.title
} %>
%>
</div>
<% end %>
<% end %>

View File

@@ -70,12 +70,12 @@
<% if voted_for?(@legislation_proposal_votes, proposal) && setting["twitter_handle"] %>
<div class="share-supported">
<%= render partial: "shared/social_share", locals: {
<%= render "shared/social_share",
title: proposal.title,
url: proposal_url(proposal),
description: proposal.summary,
mobile: proposal.title
} %>
%>
</div>
<% end %>
</div>

View File

@@ -103,13 +103,13 @@
<%= render "votes",
{ proposal: @proposal, vote_url: vote_legislation_process_proposal_path(@proposal.legislation_process_id, @proposal, value: "yes") } %>
</div>
<%= render partial: "shared/social_share", locals: {
<%= render "shared/social_share",
share_title: t("proposals.show.share"),
title: @proposal.title,
url: legislation_process_proposal_url(process_id: @process),
description: @proposal.summary,
mobile: @proposal.title
} %>
%>
</aside>
</div>
</div>

View File

@@ -42,7 +42,7 @@
</aside>
</div>
<%= render partial: "/comments/comment_tree", locals: { comment_tree: @comment_tree,
<%= render "/comments/comment_tree", comment_tree: @comment_tree,
comment_flags: @comment_flags,
display_comments_count: true } %>
display_comments_count: true %>
</section>

View File

@@ -18,12 +18,12 @@
</div>
<% @investments.each do |investment| %>
<%= render partial: "/budgets/investments/investment", locals: {
<%= render "/budgets/investments/investment",
investment: investment,
investment_ids: @investment_ids,
investment_votes: @investment_votes,
ballot: @ballot
} %>
%>
<% end %>
<%= paginate @investments %>

View File

@@ -23,12 +23,12 @@
</div>
<% @investments.each do |investment| %>
<%= render partial: "/budgets/investments/investment", locals: {
<%= render "/budgets/investments/investment",
investment: investment,
investment_ids: @investment_ids,
investment_votes: @investment_votes,
ballot: @ballot
} %>
%>
<% end %>
<div class="for-print-only">

View File

@@ -2,7 +2,7 @@
<%= render "/shared/print" %>
<%= render partial: "/budgets/investments/investment_show", locals: {
<%= render "/budgets/investments/investment_show",
investment: @investment,
investment_votes: @investment_votes
} %>
%>

View File

@@ -1 +1 @@
<%= render partial: "proposals/proposal", locals: {proposal: proposal} %>
<%= render "proposals/proposal", proposal: proposal %>

View File

@@ -4,7 +4,7 @@
timestamp: notification.timestamp,
title: notification.notifiable_title,
body: notification.notifiable_body } %>
<% link_text = render partial: "/notifications/notification_body", locals: locals %>
<% link_text = render "/notifications/notification_body", locals %>
<%= link_to_if notification.link.present?, link_text, notification.link %>
<% else %>
<p>

View File

@@ -25,7 +25,7 @@
<% else %>
<ul class="no-bullet clear notifications-list">
<% @notifications.each do |notification| %>
<%= render partial: "/notifications/notification", locals: {notification: notification} %>
<%= render "/notifications/notification", notification: notification %>
<% end %>
</ul>
<% end %>

View File

@@ -21,13 +21,13 @@
</div>
<aside class="small-12 medium-3 column margin-top">
<%= render partial: "shared/social_share", locals: {
<%= render "shared/social_share",
share_title: t("shared.share"),
title: @poll.name,
url: poll_url(@poll),
description: @poll.name,
mobile: @poll.name
} %>
%>
</aside>
</div>
</div>

View File

@@ -27,14 +27,14 @@
<h3 class="section-title-divider">
<span><%= t("polls.index.no_geozone_restricted") %></span>
</h3>
<%= render partial: "poll_group", locals: {poll_group: polls_by_geozone_restriction[false]} %>
<%= render "poll_group", poll_group: polls_by_geozone_restriction[false] %>
<% end %>
<% if polls_by_geozone_restriction[true].present? %>
<h3 class="section-title-divider">
<span><%= t("polls.index.geozone_restricted") %></span>
</h3>
<%= render partial: "poll_group", locals: {poll_group: polls_by_geozone_restriction[true]} %>
<%= render "poll_group", poll_group: polls_by_geozone_restriction[true] %>
<% end %>
<%= paginate @polls %>

View File

@@ -37,12 +37,12 @@
<% if voted_for?(@featured_proposals_votes, proposal) %>
<% if setting["twitter_handle"] %>
<div class="share-supported">
<%= render partial: "shared/social_share", locals: {
<%= render "shared/social_share",
title: proposal.title,
url: proposal_url(proposal),
description: proposal.summary,
mobile: proposal.title
} %>
%>
</div>
<% end %>
<% end %>

View File

@@ -100,7 +100,7 @@
<%= render partial: "proposals/proposal", collection: @proposals %>
<% else %>
<% @proposals.each do |proposal| %>
<%= render partial: "/proposals/proposal_minimal", locals: { proposal: proposal } %>
<%= render "/proposals/proposal_minimal", proposal: proposal %>
<% end %>
<% end %>
<% else %>

View File

@@ -21,12 +21,12 @@
<%= t("proposals.proposal.share.edit") %>
</p>
<%= render partial: "shared/social_share", locals: {
<%= render "shared/social_share",
title: @proposal.title,
url: proposal_url(@proposal),
description: @proposal.summary,
mobile: @proposal.title
} %>
%>
<% if can?(:dashboard, @proposal) %>
<div class="callout light margin">

View File

@@ -2,10 +2,10 @@
<% unless @comment_tree.nil? %>
<% can_comment = (!@budget.finished? && can?(:comment_valuation, @investment)) %>
<%= render partial: "/comments/comment_tree", locals: { comment_tree: @comment_tree,
<%= render "/comments/comment_tree", comment_tree: @comment_tree,
comment_flags: @comment_flags,
display_comments_count: false,
valuation: true,
allow_comments: can_comment,
admin_layout: true } %>
admin_layout: true %>
<% end %>

View File

@@ -5,16 +5,16 @@
<h2><%= t("valuation.budget_investments.edit.dossier") %></h2>
<% if can?(:valuate, @investment) && can?(:edit_dossier, @investment) %>
<%= render partial: "/valuation/budget_investments/dossier_form", locals: {investment: @investment} %>
<%= render "/valuation/budget_investments/dossier_form", investment: @investment %>
<% else %>
<%= render partial: "/valuation/budget_investments/dossier_detail", locals: {investment: @investment} %>
<%= render "/valuation/budget_investments/dossier_detail", investment: @investment %>
<% end %>
<%= render "valuation/budget_investments/valuation_comments" %>
<h2><%= t("valuation.budget_investments.show.preview") %></h2>
<hr>
<%= render partial: "/budgets/investments/investment_detail", locals: {investment: @investment, preview: true} %>
<%= render "/budgets/investments/investment_detail", investment: @investment, preview: true %>
<hr>
<h2><%= t("valuation.budget_investments.show.responsibles") %></h2>

View File

@@ -14,7 +14,7 @@
</div>
<hr>
<%= render partial: "/budgets/investments/investment_detail", locals: {investment: @investment, preview: true} %>
<%= render "/budgets/investments/investment_detail", investment: @investment, preview: true %>
</hr>
<% if @investment.external_url.present? %>