Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Finish asset_tag_helper

  • Loading branch information...
commit 3a03b49408939a8c5381c278a338cf6cc9685cc3 1 parent f50f79b
@zires authored
Showing with 33 additions and 7 deletions.
  1. +33 −7 lib/theme_park/rails/asset_tag_helper.rb
View
40 lib/theme_park/rails/asset_tag_helper.rb
@@ -8,22 +8,43 @@ module AssetTagHelper
#
def theme_stylesheet_link_tag(*sources)
-
+ options = sources.extract_options!
+ theme = options.delete(:theme)
+ if serve_static_assets? or !sprockets?
+ sources.collect do |source|
+ stylesheet_link_tag theme_compiled_path(source, theme)
+ end.join("\n").html_safe
+ else
+ stylesheet_link_tag(*sources)
+ end
end
#
def theme_javascript_include_tag(*sources)
-
+ options = sources.extract_options!
+ theme = options.delete(:theme)
+ if serve_static_assets? or !sprockets?
+ sources.collect do |source|
+ javascript_include_tag theme_compiled_path(source, theme)
+ end.join("\n").html_safe
+ else
+ javascript_include_tag(*sources)
+ end
end
- #
- def theme_image_path(source, theme = nil)
- return image_path(source) if theme.blank?
- if serve_static_assets?
-
+ #
+ def theme_image_tag(source, theme = nil, options = {})
+ if serve_static_assets? or !sprockets?
+ image_tag(theme_compiled_path(source, theme), options)
+ else
+ image_tag(source, options)
end
end
+ def theme_compiled_path(source, theme)
+ "/#{ThemePark.prefix}/#{theme}/#{source}"
+ end
+
# sprocket assets pipeline enabled or not.
def assets_enabled?
Rails.application.config.assets.enabled
@@ -34,6 +55,11 @@ def serve_static_assets?
Rails.application.config.serve_static_assets
end
+ # use sprockets or not.
+ def sprockets?
+ assets_enabled? && Rails.application.config.assets.digest.present?
+ end
+
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.