module Juli::Visitor::Html::TagHelper
copied from Rails
Constants
- BOOLEAN_ATTRIBUTES
Public Instance Methods
content_tag(name, content_or_options_with_block = nil, options = nil, &block)
click to toggle source
# File lib/juli/visitor/html/tag_helper.rb, line 8 def content_tag(name, content_or_options_with_block = nil, options = nil, &block) if block_given? options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) content_tag_string(name, block.call, options) else content_tag_string(name, content_or_options_with_block, options) end end
tag(name, options = nil, open = false)
click to toggle source
# File lib/juli/visitor/html/tag_helper.rb, line 4 def tag(name, options = nil, open = false) "<#{name}#{tag_options(options) if options}#{open ? ">" : " />"}" end
Private Instance Methods
content_tag_string(name, content, options)
click to toggle source
# File lib/juli/visitor/html/tag_helper.rb, line 21 def content_tag_string(name, content, options) tag_options = tag_options(options) if options "<#{name}#{tag_options}>#{content}</#{name}>" end
tag_options(options)
click to toggle source
# File lib/juli/visitor/html/tag_helper.rb, line 26 def tag_options(options) if options != {} attrs = [] options.each_pair do |key, value| if BOOLEAN_ATTRIBUTES.include?(key) attrs << key if value else attrs << %(#{key}="#{value}") if !value.nil? end end " #{attrs.sort * ' '}" unless attrs.empty? end end