Replace content_tag with new tag builder syntax
One of the main advantages of this syntax is we can now omit the content parameter when it's empty.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
module Admin::LocalCensusRecords::ImportsHelper
|
||||
def errors_for(resource, field)
|
||||
if resource.errors.include? field
|
||||
content_tag :div, class: "error" do
|
||||
tag.div class: "error" do
|
||||
resource.errors[field].join(", ")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ module ApplicationHelper
|
||||
|
||||
def back_link_to(destination = :back, text = t("shared.back"))
|
||||
link_to destination, class: "back" do
|
||||
content_tag(:span, nil, class: "icon-angle-left") + text
|
||||
tag.span(class: "icon-angle-left") + text
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ module BannersHelper
|
||||
|
||||
def banner_target_link(banner)
|
||||
link_to banner.target_url do
|
||||
content_tag(:h2, banner.title, style: "color:#{banner.font_color}") +
|
||||
content_tag(:h3, banner.description, style: "color:#{banner.font_color}")
|
||||
tag.h2(banner.title, style: "color:#{banner.font_color}") +
|
||||
tag.h3(banner.description, style: "color:#{banner.font_color}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ module BudgetInvestmentsHelper
|
||||
translation = t("admin.budget_investments.index.list.#{column}")
|
||||
|
||||
link_to(
|
||||
safe_join([translation, content_tag(:span, "", class: "icon-sortable #{icon}")]),
|
||||
safe_join([translation, tag.span(class: "icon-sortable #{icon}")]),
|
||||
admin_budget_budget_investments_path(sort_by: column, direction: direction)
|
||||
)
|
||||
end
|
||||
|
||||
@@ -4,9 +4,9 @@ module BudgetsHelper
|
||||
end
|
||||
|
||||
def heading_name_and_price_html(heading, budget)
|
||||
content_tag :div do
|
||||
tag.div do
|
||||
concat(heading.name + " ")
|
||||
concat(content_tag(:span, budget.formatted_heading_price(heading)))
|
||||
concat(tag.span(budget.formatted_heading_price(heading)))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ module DocumentsHelper
|
||||
def document_item_link(document)
|
||||
info_text = "#{document.humanized_content_type} | #{number_to_human_size(document.attachment_file_size)}"
|
||||
|
||||
link_to safe_join([document.title, content_tag(:small, "(#{info_text})")], " "),
|
||||
link_to safe_join([document.title, tag.small("(#{info_text})")], " "),
|
||||
document.attachment.url,
|
||||
target: "_blank",
|
||||
title: t("shared.target_blank")
|
||||
|
||||
@@ -71,7 +71,7 @@ module GlobalizeHelper
|
||||
|
||||
current_translation = resource.translation_for(selected_locale(resource))
|
||||
if current_translation.errors.added? :base, :translations_too_short
|
||||
content_tag :div, class: "small error" do
|
||||
tag.div class: "small error" do
|
||||
current_translation.errors[:base].join(", ")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module LayoutsHelper
|
||||
def layout_menu_link_to(text, path, is_active, options)
|
||||
if is_active
|
||||
content_tag(:span, t("shared.you_are_in"), class: "show-for-sr") + " " +
|
||||
tag.span(t("shared.you_are_in"), class: "show-for-sr") + " " +
|
||||
link_to(text, path, options.merge(class: "is-active"))
|
||||
else
|
||||
link_to(text, path, options)
|
||||
|
||||
@@ -25,8 +25,7 @@ module MapLocationsHelper
|
||||
|
||||
def render_map(map_location, parent_class, editable, remove_marker_label, investments_coordinates = nil)
|
||||
map_location = MapLocation.new if map_location.nil?
|
||||
map = content_tag :div, "",
|
||||
id: dom_id(map_location),
|
||||
map = tag.div id: dom_id(map_location),
|
||||
class: "map_location map",
|
||||
data: prepare_map_settings(map_location, editable, parent_class, investments_coordinates)
|
||||
map += map_location_remove_marker(map_location, remove_marker_label) if editable
|
||||
@@ -34,7 +33,7 @@ module MapLocationsHelper
|
||||
end
|
||||
|
||||
def map_location_remove_marker(map_location, text)
|
||||
content_tag :div, class: "margin-bottom" do
|
||||
tag.div class: "margin-bottom" do
|
||||
content_tag :a,
|
||||
id: map_location_remove_marker_link_id(map_location),
|
||||
href: "#",
|
||||
|
||||
@@ -2,17 +2,15 @@ module MilestonesHelper
|
||||
def progress_tag_for(progress_bar)
|
||||
text = number_to_percentage(progress_bar.percentage, precision: 0)
|
||||
|
||||
content_tag :div, class: "progress",
|
||||
tag.div class: "progress",
|
||||
role: "progressbar",
|
||||
"aria-valuenow": "#{progress_bar.percentage}",
|
||||
"aria-valuetext": "#{progress_bar.percentage}%",
|
||||
"aria-valuemax": ProgressBar::RANGE.max,
|
||||
"aria-valuemin": "0",
|
||||
tabindex: "0" do
|
||||
content_tag(:span, "",
|
||||
class: "progress-meter",
|
||||
style: "width: #{progress_bar.percentage}%;") +
|
||||
content_tag(:p, text, class: "progress-meter-text")
|
||||
tag.span(class: "progress-meter", style: "width: #{progress_bar.percentage}%;") +
|
||||
tag.p(text, class: "progress-meter-text")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ module StatsHelper
|
||||
def chart_tag(opt = {})
|
||||
opt[:data] ||= {}
|
||||
opt[:data][:graph] = admin_api_stats_path(chart_data(opt))
|
||||
content_tag :div, "", opt
|
||||
tag.div opt
|
||||
end
|
||||
|
||||
def chart_data(opt = {})
|
||||
@@ -26,7 +26,7 @@ module StatsHelper
|
||||
def budget_investments_chart_tag(opt = {})
|
||||
opt[:data] ||= {}
|
||||
opt[:data][:graph] = admin_api_stats_path(budget_investments: true)
|
||||
content_tag :div, "", opt
|
||||
tag.div opt
|
||||
end
|
||||
|
||||
def number_to_stats_percentage(number, options = {})
|
||||
@@ -34,9 +34,9 @@ module StatsHelper
|
||||
end
|
||||
|
||||
def number_with_info_tags(number, text, html_class: "")
|
||||
content_tag :p, class: "number-with-info #{html_class}".strip do
|
||||
content_tag :span, class: "content" do
|
||||
content_tag(:span, number, class: "number") + content_tag(:span, text, class: "info")
|
||||
tag.p class: "number-with-info #{html_class}".strip do
|
||||
tag.span class: "content" do
|
||||
tag.span(number, class: "number") + tag.span(text, class: "info")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,7 +34,7 @@ module TranslatableFormHelper
|
||||
|
||||
def fields_for_locale(locale)
|
||||
fields_for_translation(@translations[locale]) do |translations_form|
|
||||
@template.content_tag :div, translations_options(translations_form.object, locale) do
|
||||
@template.tag.div translations_options(translations_form.object, locale) do
|
||||
@template.concat translations_form.hidden_field(
|
||||
:_destroy,
|
||||
value: !@template.enabled_locale?(translations_form.object.globalized_model, locale),
|
||||
|
||||
@@ -15,8 +15,8 @@ module UsersHelper
|
||||
if commentable.nil?
|
||||
deleted_commentable_text(comment)
|
||||
elsif commentable.hidden?
|
||||
content_tag(:del, commentable.title) + " " +
|
||||
content_tag(:span, "(" + deleted_commentable_text(comment) + ")", class: "small")
|
||||
tag.del(commentable.title) + " " +
|
||||
tag.span("(#{deleted_commentable_text(comment)})", class: "small")
|
||||
else
|
||||
link_to(commentable.title, comment)
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<tbody>
|
||||
<% @officer_assignments.each do |officer_assignment| %>
|
||||
<tr id="<%= dom_id officer_assignment %>">
|
||||
<td><%= l(officer_assignment.date.to_date) %> <%= content_tag :strong, t("polls.final_date") if officer_assignment.final %></td>
|
||||
<td><%= l(officer_assignment.date.to_date) %> <%= tag.strong t("polls.final_date") if officer_assignment.final %></td>
|
||||
<td><%= booth_name_with_location(officer_assignment.booth_assignment.booth) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
<div id="budget-investments" class="budget-investments-list small-12 medium-9 column">
|
||||
|
||||
<div class="small-12 search-results">
|
||||
<%= content_tag(:h2, t("management.budget_investments.filters.unfeasible")) if params[:unfeasible].present? %>
|
||||
<%= content_tag(:h2, t("management.budget_investments.filters.heading", heading: @heading.name)) if @heading.present? %>
|
||||
<%= tag.h2 t("management.budget_investments.filters.unfeasible") if params[:unfeasible].present? %>
|
||||
<%= tag.h2 t("management.budget_investments.filters.heading", heading: @heading.name) if @heading.present? %>
|
||||
<% if params[:search].present? %>
|
||||
<h2>
|
||||
<%= page_entries_info @investments %>
|
||||
|
||||
@@ -21,7 +21,7 @@ class ConsulFormBuilder < FoundationRailsHelper::FormBuilder
|
||||
|
||||
def check_box(attribute, options = {})
|
||||
if options[:label] != false
|
||||
label = content_tag(:span, sanitize(label_text(object, attribute, options[:label])), class: "checkbox")
|
||||
label = tag.span sanitize(label_text(object, attribute, options[:label])), class: "checkbox"
|
||||
|
||||
super(attribute, options.merge(label: label, label_options: label_options_for(options)))
|
||||
else
|
||||
@@ -70,7 +70,7 @@ class ConsulFormBuilder < FoundationRailsHelper::FormBuilder
|
||||
|
||||
def help_text(attribute, options)
|
||||
if options[:hint]
|
||||
content_tag :span, options[:hint], class: "help-text", id: help_text_id(attribute, options)
|
||||
tag.span options[:hint], class: "help-text", id: help_text_id(attribute, options)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user