# frozen_string_literal: true

module HexletCode
  module Tag
    def self.build(tag_name, options = {})
      attrs = options.map { |name, value| " #{name}=\"#{value}\"" }.join('')
      html = "<#{tag_name}#{attrs}>"

      return html unless block_given?

      "#{html}#{yield}</#{tag_name}>"
    end
  end
end
