Sha256: 1cffd6000af37959c94e87eea2506b2c4b0fd954c64e3388071c4e7481c7a856
Contents?: true
Size: 1.11 KB
Versions: 12
Compression:
Stored size: 1.11 KB
Contents
module Alchemy module Ingredients class TextView < BaseView attr_reader :disable_link delegate :dom_id, :link, :link_title, :link_target, to: :ingredient # @param ingredient [Alchemy::Ingredient] # @param disable_link [Boolean] (false) Whether to disable the link even if the picture has a link. # @param html_options [Hash] Options that will be passed to the a tag. def initialize(ingredient, disable_link: nil, html_options: {}) super(ingredient, html_options: html_options) @disable_link = settings_value(:disable_link, value: disable_link, default: false) end def call if disable_link? dom_id.present? ? anchor : value else link_to(value, url_for(link), { id: dom_id.presence, title: link_title, target: link_target }.merge(html_options)) end.html_safe end private def anchor content_tag(:a, value, {id: dom_id}.merge(html_options)) end def disable_link? link.blank? || disable_link end end end end
Version data entries
12 entries across 12 versions & 1 rubygems