Module: Tipsy::Helpers::Tag
Instance Method Summary
collapse
Methods included from Capture
#capture, #content_for, #content_for?
Instance Method Details
#content_tag(name, content = nil, html_attrs = {}, &capt) ⇒ Object
10
11
12
13
14
|
# File 'lib/tipsy/helpers/tag.rb', line 10
def content_tag(name, content = nil, html_attrs = {}, &capt)
buffer = "<#{name}#{make_attributes(html_attrs)}>"
content = capture(&capt) if block_given? and content.nil?
"<#{name}#{make_attributes(html_attrs)}>#{content}</#{name}>"
end
|
#link_to(text, path, html_attrs = {}) ⇒ Object
16
17
18
|
# File 'lib/tipsy/helpers/tag.rb', line 16
def link_to(text, path, html_attrs = {})
content_tag(:a, text, html_attrs.merge!('href' => path))
end
|
#mail_to(addr, text = nil, html_attrs = {}) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/tipsy/helpers/tag.rb', line 20
def mail_to(addr, text = nil, html_attrs = {})
unless text || text.is_a?(Hash)
html_attrs = text if text
text = addr
end
link_to(text, "mailto:#{addr}", html_attrs)
end
|
#tag(name, html_attrs = {}, open = false) ⇒ Object
6
7
8
|
# File 'lib/tipsy/helpers/tag.rb', line 6
def tag(name, html_attrs = {}, open = false)
"<#{name}#{make_attributes(html_attrs)}#{open ? ">" : " />"}"
end
|