class BlueDoc::SML::Rules::Image

Public Class Methods

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

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

  attr_html = html_attrs(
    src: attrs[:src],
    alt: attrs[:name],
    width: attrs[:width],
    height: attrs[:height]
  )

  %(<img#{attr_html}>)
end