Sha256: 56755b362c26a7f20644ff4e92259c5a2685c4423ecbdc81112762fee82a3ffb

Contents?: true

Size: 767 Bytes

Versions: 1

Compression:

Stored size: 767 Bytes

Contents

module Munge
  module Helper
    module Tag
      def empty_tag(name, options = {})
        options_str = options.map { |k, v| %(#{k}="#{v}") }.join(" ")

        if options_str == ""
          "<#{name} />"
        else
          "<#{name} #{options_str} />"
        end
      end

      def content_tag(name, content = nil, options = {}, &block)
        if content.is_a?(Hash)
          options = content
          content = nil
        end

        options_str = options.map { |k, v| %(#{k}="#{v}") }.join(" ")

        content_str =
          if content
            content
          elsif block_given?
            capture(&block)
          else
            ""
          end

        "<#{name} #{options_str}>#{content_str}</#{name}>"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
munge-0.5.0 lib/munge/helper/tag.rb