Sha256: 5402078ac9dbc5c06c67012b73abf4c4dc7cc0de74d5d52473e72c87941f9bf3
Contents?: true
Size: 748 Bytes
Versions: 1
Compression:
Stored size: 748 Bytes
Contents
module Navigator # Renders a HTML tag. class Tag attr_reader :name, :content def initialize name, content = nil, attributes = {}, activator = Navigator::TagActivator.new @name = name @content = content @attributes = attributes.with_indifferent_access @activator = activator end def prefix ["<#{name}", formatted_attributes, '>'].compact * '' end def suffix "</#{name}>" end def render [prefix, content, suffix].compact * '' end private attr_reader :attributes, :activator def formatted_attributes attrs = activator.activate(attributes).map { |key, value| %(#{key}="#{value}") } * ' ' attrs.empty? ? nil : " #{attrs}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
navigator-0.7.0 | lib/navigator/tag.rb |