Sha256: dff94d2838ae74040c2260584985320c7d65cf4e4ac94e8e171e1079cfeefd1f

Contents?: true

Size: 677 Bytes

Versions: 5

Compression:

Stored size: 677 Bytes

Contents

# frozen_string_literal: true

module Kitchen::Directions::BakeIframes
  class V1
    def bake(outer_element:)
      iframes = outer_element.search('iframe')
      return unless iframes.any?

      iframes.each do |iframe|
        iframe.wrap('<div class="os-has-iframe" data-type="alternatives">')
        iframe.add_class('os-is-iframe')
        link_ref = iframe[:src]
        next unless link_ref

        iframe = iframe.parent
        iframe.add_class('os-has-link')
        iframe.prepend(child:
          <<~HTML
            <a class="os-is-link" href="#{link_ref}" target="_window">#{I18n.t(:iframe_link_text)}</a>
          HTML
        )
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
openstax_kitchen-12.2.0 lib/kitchen/directions/bake_iframes/v1.rb
openstax_kitchen-12.1.0 lib/kitchen/directions/bake_iframes/v1.rb
openstax_kitchen-12.0.0 lib/kitchen/directions/bake_iframes/v1.rb
openstax_kitchen-11.2.0 lib/kitchen/directions/bake_iframes/v1.rb
openstax_kitchen-11.1.0 lib/kitchen/directions/bake_iframes/v1.rb