Sha256: 6a0f8dc4a79d8f9a7113f52cc74f602915e6c99209461ebd8c144e714daccf52

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 Bytes

Contents

class RailsExtras
  module Helpers
    module Tag
      def add_tag(name=nil, options={}, &block)
        if block_given?
          if block.arity == 1
            result = ActiveSupport::SafeBuffer.new
            def result.space(text)
              self << text
              self << ' '
            end
            def result.add(text)
              self << text
            end
            block.call(result)
            if name
              content_tag(name, options) do
                result
              end
            else
              result
            end
          else
            if name
              content_tag(name, options) do
                block.call
              end
            else
              block.call
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_extras-0.1.2 lib/rails_extras/helpers/tag.rb
rails_extras-0.1.1 lib/rails_extras/helpers/tag.rb
rails_extras-0.1.0 lib/rails_extras/helpers/tag.rb