class GovukPublishingComponents::Presenters::ImageCardHelper
Attributes
extra_details[R]
extra_details_no_indent[R]
heading_text[R]
href[R]
href_data_attributes[R]
image_loading[R]
lang[R]
large[R]
metadata[R]
Public Class Methods
new(local_assigns)
click to toggle source
# File lib/govuk_publishing_components/presenters/image_card_helper.rb, line 9 def initialize(local_assigns) @href = local_assigns[:href] @href_data_attributes = local_assigns[:href_data_attributes] @extra_details = local_assigns[:extra_details] || [] @image_src = local_assigns[:image_src] @image_alt = local_assigns[:image_alt] || "" @image_loading = local_assigns[:image_loading] || "auto" @context = local_assigns[:context] @description = local_assigns[:description] @large = local_assigns[:large] @heading_text = local_assigns[:heading_text] @extra_details_no_indent = local_assigns[:extra_details_no_indent] @metadata = local_assigns[:metadata] @lang = local_assigns[:lang] end
Public Instance Methods
context()
click to toggle source
# File lib/govuk_publishing_components/presenters/image_card_helper.rb, line 44 def context return unless @context content_tag(:p, class: "gem-c-image-card__context") do if @context[:date] date = content_tag(:time, l(@context[:date], format: "%e %B %Y"), datetime: @context[:date].iso8601, lang: "en") dash = content_tag(:span, " — ", 'aria-hidden': true) if @context[:text] date.concat(dash).concat(@context[:text]) else date end else @context[:text] end end end
description()
click to toggle source
# File lib/govuk_publishing_components/presenters/image_card_helper.rb, line 63 def description content_tag(:div, @description, class: "gem-c-image-card__description") if @description end
image()
click to toggle source
# File lib/govuk_publishing_components/presenters/image_card_helper.rb, line 36 def image if @image_src content_tag(:figure, class: "gem-c-image-card__image-wrapper") do image_tag(@image_src, class: "gem-c-image-card__image", alt: @image_alt, loading: @image_loading) end end end
is_tracking?()
click to toggle source
# File lib/govuk_publishing_components/presenters/image_card_helper.rb, line 25 def is_tracking? return true if @href_data_attributes if @extra_details @extra_details.each do |link| return true if link[:data_attributes] end end false end