class BlueDoc::SML::Rules::Video

Public Class Methods

match?(node) click to toggle source
# File lib/bluedoc/sml/rules/video.rb, line 5
def self.match?(node)
  tag_name(node) == "video"
end
to_html(node, opts = {}) click to toggle source
# File lib/bluedoc/sml/rules/video.rb, line 9
    def self.to_html(node, opts = {})
      attrs = attributes(node)

      return "" if attrs[:src].blank?

      width = attrs[:width]
      if width == 0 || width.blank?
        width = "100%"
      end

      video_attrs = html_attrs(
        width: width
      )

      nid_attr = name_by_attrs(attrs)

      out = <<~HTML
      <video controls preload="no"#{video_attrs}#{nid_attr}>
        <source src="#{attrs[:src]}" type="#{attrs[:type]}">
      </video>
      HTML

      out
    end