Repository URL to install this package:
|
Version:
0.9.0 ▾
|
module EUtils
def html_tag_requisites escape, *args
content, attrs = nil, {}
args.each {|a| a.is_a?(Hash) ? attrs.update(a) : content = a}
[
escape && content ? CGI.escape_html(content.to_s) : content,
html_tag_attrs(attrs)
]
end
module_function :html_tag_requisites
def html_tag_attrs attrs
attrs.inject('') do |s,kv|
s << ' %s="%s"' % kv.map {|x| CGI.escape_html(x.to_s)}
end
end
module_function :html_tag_attrs
def requisites_for_link_to escape, controller, action_or_link = nil, anchor = nil, attributes = {}, &proc
if action_or_link.is_a?(Hash)
attributes = action_or_link
action_or_link = nil
elsif anchor.is_a?(Hash)
attributes = anchor
anchor = nil
end
(route = controller[action_or_link]) && (action_or_link = route)
anchor ||= proc ? proc.call : action_or_link
[
action_or_link ? CGI.escapeHTML(action_or_link.to_s) : 'javascript:void(null);',
attributes.is_a?(Hash) ? EUtils.html_tag_attrs(attributes) : '',
escape && anchor ? CGI.escapeHTML(anchor.to_s) : anchor
]
end
module_function :requisites_for_link_to
end