Sha256: fa7af63c4562b93a0a476cf3b24ecce6b0b34c298f7c734de7fb96bbb81b2edc
Contents?: true
Size: 911 Bytes
Versions: 1
Compression:
Stored size: 911 Bytes
Contents
module Asset module Helpers # Script tags def script_tag(*paths) tag('js', *paths) do |src| %{<script src="#{src}"></script>} end end # Style tags def style_tag(*paths) tag('css', *paths) do |src| %{<link href="#{src}" media="all" rel="stylesheet" type="text/css">} end end # Image tags def image_tag(path) b = ::Asset.images[path] rescue nil %{<img src="/assets/images/#{CGI.escapeHTML(path)}#{b ? "?#{b}" : ''}">} rescue path end private # Build the tags def tag(type, *paths, &block) paths.map do |path| # Yield the source back to the tag builder item = ::Asset.manifest.find{|i| i.path == path} # Src is same as path if item not found item ? item.files.map{|src| yield(%{/assets/#{type}/#{src}})} : yield(path) end.flatten.join("\n") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
asset-0.1.1 | lib/assets/helpers.rb |