Module: ActionView::Helpers::AssetTagHelper
- Defined in:
- lib/ezcript/application_helper_extension.rb
Instance Method Summary collapse
- #complete_link_to(*args, &block) ⇒ Object
- #image_tag(source, options = {}) ⇒ Object
- #javascript_src_tag(source, options) ⇒ Object
- #stylesheet_tag(source, options) ⇒ Object
Instance Method Details
#complete_link_to(*args, &block) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/ezcript/application_helper_extension.rb', line 137 def complete_link_to(*args, &block) if block_given? = args.first || {} = args.second link_to(capture(&block), , ) else name = args[0] = args[1] || {} = args[2] = (, ) url = url_for() url = File.join(Compass::Info.app_host, url).to_s unless url.downcase.starts_with?("http") if = .stringify_keys href = ['href'] = () else = nil end href_attr = "href=\"#{html_escape(url)}\"" unless href "<a #{href_attr}#{tag_options}>#{(name || url)}</a>".html_safe end end |
#image_tag(source, options = {}) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/ezcript/application_helper_extension.rb', line 116 def image_tag(source, = {}) .symbolize_keys! src = [:src] = "#{Compass::Info.asset_dir}#{path_to_image(source)}" unless src =~ /^cid:/ [:alt] = .fetch(:alt){ File.basename(src, '.*').capitalize } end if size = .delete(:size) [:width], [:height] = size.split("x") if size =~ %r{^\d+x\d+$} end if mouseover = .delete(:mouseover) [:onmouseover] = "this.src='#{path_to_image(mouseover)}'" [:onmouseout] = "this.src='#{src}'" end tag("img", ) end |
#javascript_src_tag(source, options) ⇒ Object
110 111 112 113 114 |
# File 'lib/ezcript/application_helper_extension.rb', line 110 def javascript_src_tag(source, ) s= "#{Compass::Info.asset_dir}/javascripts/#{source}" s << ".js" unless s.end_with?(".js") content_tag("script", "", { "type" => Mime::JS, "src" => path_to_javascript(s) }.merge()) end |
#stylesheet_tag(source, options) ⇒ Object
105 106 107 108 |
# File 'lib/ezcript/application_helper_extension.rb', line 105 def stylesheet_tag(source, ) s= "#{Compass::Info.asset_dir}/stylesheets/#{source}" tag("link", { "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => html_escape(path_to_stylesheet(s)) }.merge(), false, false) end |