module EUtils
Public Class Methods
html_tag_attrs(attrs)
click to toggle source
# File lib/el/utils.rb, line 12 def html_tag_attrs attrs attrs.inject('') do |s,kv| s << ' %s="%s"' % kv.map {|x| CGI.escape_html(x.to_s)} end end
html_tag_requisites(escape, *args)
click to toggle source
# File lib/el/utils.rb, line 2 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
requisites_for_link_to(escape, controller, action_or_link = nil, anchor = nil, attributes = {})
click to toggle source
# File lib/el/utils.rb, line 19 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
Private Instance Methods
html_tag_attrs(attrs)
click to toggle source
# File lib/el/utils.rb, line 12 def html_tag_attrs attrs attrs.inject('') do |s,kv| s << ' %s="%s"' % kv.map {|x| CGI.escape_html(x.to_s)} end end
html_tag_requisites(escape, *args)
click to toggle source
# File lib/el/utils.rb, line 2 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
requisites_for_link_to(escape, controller, action_or_link = nil, anchor = nil, attributes = {})
click to toggle source
# File lib/el/utils.rb, line 19 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