Sha256: 7736caffe22b6356cfc980efca6db728d552b793efdadc9f6677051506cafe1d

Contents?: true

Size: 986 Bytes

Versions: 4

Compression:

Stored size: 986 Bytes

Contents

module TopHat
  module HtmlHelper

    def html_tag(options={})
      if options[:xmlns] && options[:xmlns].kind_of?(Array)
        options.delete(:xmlns).each do |xmlns|
          if xmlns.kind_of?(Hash)
            options["xmlns:#{xmlns[:prefix]}"] = xmlns[:url]
          else
            options['xmlns'] = xmlns
          end
        end
      end

      if options[:prefix]
        if options[:prefix].kind_of?(Hash)
          prefix_options = options.delete(:prefix)
          options['prefix'] = "#{prefix_options[:prefix]}: #{prefix_options[:url]}"
        elsif options[:prefix].kind_of?(Array)
          prefixes = []
          options.delete(:prefix).each do |prefix|
            if prefix.kind_of?(Hash)
              prefixes << "#{prefix[:prefix]}: #{prefix[:url]}"
            else
              prefixes << prefix
            end
          end

          options['prefix'] = prefixes.join(' ')
        end
      end

      tag(:html, options, true)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tophat-2.0.0 lib/tophat/html.rb
tophat-1.7.2 lib/tophat/html.rb
tophat-1.7.1 lib/tophat/html.rb
tophat-1.7.0 lib/tophat/html.rb