Sha256: 00b1b25987c38b9891c3dae3e5169317a3af401726f2b80ad359d5d76b65299e
Contents?: true
Size: 1.32 KB
Versions: 25
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true module Maglev module Content class Link < Base def href link[:href] end def text link[:text] end def with_text? !!setting.options[:with_text] end def open_new_window? !!link[:open_new_window] end def target_blank open_new_window? ? '_blank' : nil end def to_s href end def tag(view_context, options = {}, &block) captured_content = view_context.capture(&block) if block_given? view_context.link_to( captured_content || text_tag(view_context), href, { data: (options.delete(:data) || {}).merge(tag_data), target: target_blank }.merge(options) ) end private def link @link ||= if content.is_a?(String) { href: content, link_type: 'url', open_new_window: false } elsif content content else {} end.symbolize_keys end # rubocop:disable Rails/OutputSafety def text_tag(view_context) view_context.tag.span(text, **{ data: { maglev_id: "#{tag_id}.text" } }).html_safe end # rubocop:enable Rails/OutputSafety end end end
Version data entries
25 entries across 25 versions & 1 rubygems