Sha256: 6f30c47396976375516b667221f8a7936f38156b1cdd1e8c8d73e8056f815672

Contents?: true

Size: 768 Bytes

Versions: 6

Compression:

Stored size: 768 Bytes

Contents

module Munge
  module Helpers
    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

6 entries across 6 versions & 1 rubygems

Version Path
munge-0.10.0 lib/munge/helpers/tag.rb
munge-0.9.0 lib/munge/helpers/tag.rb
munge-0.8.0 lib/munge/helpers/tag.rb
munge-0.7.1 lib/munge/helpers/tag.rb
munge-0.7.0 lib/munge/helpers/tag.rb
munge-0.6.0 lib/munge/helpers/tag.rb