Sha256: 00440d98f69f59d0d189cf4a85f234ee72420aebfce64fb377d950f574a653b9

Contents?: true

Size: 1.07 KB

Versions: 14

Compression:

Stored size: 1.07 KB

Contents

def guide_card
  @guide_card ||= determine_guide_card
end

format :html do
  view :guide, unknown: true, cache: :never, wrap: :slot do
    guide
  end

  def guide
    return "" unless (text = guide_text).present?

    wrap_with :div, class: classy("guide-text") do
      prepend_guide_edit_link text
    end
  end

  def alert_guide
    rendered = guide
    return "" unless rendered.present?

    alert(:secondary, true, false, class: "guide") { rendered }
  end

  private

  def prepend_guide_edit_link guide_text
    return guide_text unless guide_card.ok?(:update)

    edit_link = with_nest_mode(:normal) { nest(guide_card, view: :edit_link) }
    "<span class='d-none'>#{edit_link}</span>#{guide_text}"
  end

  def guide_text
    return "" unless guide_card

    with_nest_mode :normal do
      nest guide_card, view: :core
    end
  end

  delegate :guide_card, to: :card
end

private

def determine_guide_card
  guide_card = rule_card :guide
  return unless guide_card

  guide_card = guide_card.first_card if guide_card.type_id == PointerID
  guide_card if guide_card.ok?(:read)
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
card-mod-help-0.18.1 set/all/guide.rb
card-mod-help-0.18.0 set/all/guide.rb
card-mod-help-0.17.0 set/all/guide.rb
card-mod-help-0.16.0 set/all/guide.rb
card-mod-help-0.15.6 set/all/guide.rb
card-mod-help-0.15.5 set/all/guide.rb
card-mod-help-0.15.4 set/all/guide.rb
card-mod-help-0.15.3 set/all/guide.rb
card-mod-help-0.15.2.pre1 set/all/guide.rb
card-mod-help-0.15.1.1 set/all/guide.rb
card-mod-help-0.15.1 set/all/guide.rb
card-mod-help-0.15.0 set/all/guide.rb
card-mod-help-0.14.2 set/all/guide.rb
card-mod-help-0.14.1 set/all/guide.rb