0
def self.included(base)
0
+ include AssignmentMethods
0
extend SweetAssetsShortcuts
0
include AppendAssetsAfterRescue
0
module SweetAssetsShortcuts
0
def style_like(*assets)
0
options = assets.extract_options!
0
-
assets.each {|asset| before_filter "style_like_#{asset}".intern, options }0
+
before_filter Proc.new {|controller| controller.style_like *assets }, options0
def script_like(*assets)
0
options = assets.extract_options!
0
-
assets.each {|asset| before_filter "script_like_#{asset}".intern, options}0
+
before_filter Proc.new {|controller| controller.script_like *assets }, options0
+ module AssignmentMethods
0
+ def style_like(*styles)
0
+ styles.each do |style|
0
+ sweet_assets[:stylesheets][style.ends_with?('!') ? :bottom : :top] << style.gsub(/!$/, '')
0
+ def script_like(*scripts)
0
+ scripts.each do |script|
0
+ sweet_assets[:javascripts][script.ends_with?('!') ? :bottom : :top] << script.gsub(/!$/, '')
0
+ self.is_a?(ActionView::Base) ?
0
+ controller.instance_variable_get("@sweet_assets") :
0
def method_missing_with_sweet_assets(method_name, *args, &block)
0
- if match = method_name.to_s.match(/^style_like_(\w+)(\!)?$/)
0
- @sweet_assets[:stylesheets][match[2] ? :bottom : :top] << match[1]
0
- elsif match = method_name.to_s.match(/^script_like_(\w+)(\!)?$/)
0
- @sweet_assets[:javascripts][match[2] ? :bottom : :top] << match[1]
0
+ if match = method_name.to_s.match(/^(style_like|script_like)_(\w+!?)$/)
0
+ send match[1], match[2]
0
method_missing_without_sweet_assets(method_name, *args, &block)
0
def style_like_current_controller
0
-
@sweet_assets[:stylesheets][:bottom] << controller_name0
+
style_like "#{controller_name}!"0
def script_like_current_controller
0
-
@sweet_assets[:javascripts][:bottom] << controller_name0
+
script_like "#{controller_name}!"0
def stylesheet_tags(placement)
0
files = @assets[:stylesheets][placement].dup
0
files = files.select {|file| File.exists?("#{STYLESHEETS_DIR}/#{file}.css") } unless RAILS_ENV.eql?('test')
0
return '' if files.blank?
0
files << {:cache => "sweet_stylesheets_#{files.join(',')}" } if ActionController::Base.perform_caching
0
def javascript_tags(placement)
0
files = @assets[:javascripts][placement].dup
0
files = files.select {|file| File.exists?("#{JAVASCRIPTS_DIR}/#{file}.js") } unless RAILS_ENV.eql?('test')
0
return '' if files.blank?
0
files << {:cache => "sweet_javascripts_#{files.join(',')}" } if ActionController::Base.perform_caching
Comments
No one has commented yet.