Sha256: 1014a849b68b08ec177aeded8f91d0b84e0d8e194fb5ecdb55c8b9666214476b

Contents?: true

Size: 580 Bytes

Versions: 1

Compression:

Stored size: 580 Bytes

Contents

module RatPack
  module Tag    
    def tag(name, contents = nil, attrs = {}, &block)
      attrs, contents = contents, nil if contents.is_a?(Hash)
      contents = capture(&block) if block_given?
      open_tag(name, attrs) + contents.to_s + close_tag(name)
    end

    def open_tag(name, attrs = nil)
      "<#{name}#{' ' + attrs.to_html_attributes unless attrs.blank?}>"
    end
  
    def close_tag(name)
      "</#{name}>"
    end
  
    def self_closing_tag(name, attrs = nil)
      "<#{name}#{' ' + attrs.to_html_attributes if attrs && !attrs.empty?}/>"
    end 
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
BrianTheCoder-ratpack-0.2.0 lib/ratpack/tag.rb