module GithubbishAssets::Helper
Public Instance Methods
bundle_files?()
click to toggle source
# File lib/githubbish_assets/helper.rb, line 3 def bundle_files? Rails.env.production? || Rails.env.staging? || params[:bundle] || cookies[:bundle] == "yes" end
css_use(*bundles)
click to toggle source
# File lib/githubbish_assets/helper.rb, line 11 def css_use(*bundles) @css_bundles = ((@css_bundles || []) + bundles.map(&:to_s)).compact.uniq end
javascript_bundle(*sources)
click to toggle source
# File lib/githubbish_assets/helper.rb, line 15 def javascript_bundle(*sources) sources = sources.to_a bundle_files? ? javascript_include_bundles(sources) : javascript_include_files(sources) end
javascript_dev(*sources)
click to toggle source
# File lib/githubbish_assets/helper.rb, line 34 def javascript_dev(*sources) output = "" sources = sources.to_a dev = Rails.env.development? || Rails.env.test? sources.each do |pair| output << javascript_src_tag(dev ? "dev/#{pair[0]}" : pair[1], {}) end output.html_safe end
javascript_include_bundles(bundles)
click to toggle source
This method assumes you have manually bundled js using a rake command or similar. So there better be bundle_* files.
# File lib/githubbish_assets/helper.rb, line 22 def javascript_include_bundles(bundles) output = "" bundles.each do |bundle| output << javascript_src_tag("bundle_#{bundle}", {}) + "\n" end output.html_safe end
javascript_include_files(bundles)
click to toggle source
# File lib/githubbish_assets/helper.rb, line 30 def javascript_include_files(bundles) _gh_include_files("public/javascripts", ".js", bundles) { |file| javascript_src_tag(file, {}) } end
js_use(*bundles)
click to toggle source
# File lib/githubbish_assets/helper.rb, line 7 def js_use(*bundles) @js_bundles = ((@js_bundles || []) + bundles.map(&:to_s)).compact.uniq end
stylesheet_bundle(*sources)
click to toggle source
# File lib/githubbish_assets/helper.rb, line 44 def stylesheet_bundle(*sources) opts = sources.extract_options! sources = sources.to_a if bundle_files? stylesheet_include_bundles(sources, opts) else stylesheet_include_files(sources, opts) end end
stylesheet_include_bundles(bundles, opts = {})
click to toggle source
This method assumes you have manually bundled css using a rake command or similar. So there better be bundle_* files.
# File lib/githubbish_assets/helper.rb, line 57 def stylesheet_include_bundles(bundles, opts = {}) stylesheet_link_tag(bundles.collect{ |b| "bundle_#{b}"}, opts) end
stylesheet_include_files(bundles, opts = {})
click to toggle source
# File lib/githubbish_assets/helper.rb, line 61 def stylesheet_include_files(bundles, opts = {}) _gh_include_files("public/stylesheets", ".css", bundles) do |file| stylesheet_link_tag(file, opts) end end
Private Instance Methods
_gh_include_files(asset_root, ext, bundles) { |relative_path_from.to_s| ... }
click to toggle source
# File lib/githubbish_assets/helper.rb, line 69 def _gh_include_files(asset_root, ext, bundles) p_asset_root = Rails.root + asset_root output = "" bundles.each do |bundle| files = RecursiveLister[p_asset_root + bundle.to_s, ext] files.each do |file| output << yield(file.relative_path_from(p_asset_root).to_s) << "\n" end end output.html_safe end