public
Rubygem
Description: Rails Plugin - a Ruby way to manage your stylesheets and javascripts. Don't put all your assets in your layout; define what you need where you need them.
Homepage: http://6brand.com
Clone URL: git://github.com/JackDanger/sweet_assets.git
Search Repo:
updating sweet assets plugin - removing duplicate asset inclusion

git-svn-id: http://svn.6brand.com/projects/plugins/sweet_assets@395 
7491b73d-821b-0410-9297-ad1f6b5b4194
studioda (author)
Thu Feb 28 07:03:19 -0800 2008
commit  e627e1cff87d914297d380af96d3ef17cba02b35
tree    d34a96dec8f21edf688f4c7c0afbc3b15e4a207f
parent  e1232281357a247916d2848176c073e0baece93c
...
39
40
41
42
43
 
44
45
46
47
...
50
51
52
53
 
54
55
56
57
58
59
60
61
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
64
65
...
39
40
41
 
 
42
43
44
45
46
...
49
50
51
 
52
53
54
55
56
 
 
 
 
 
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
0
@@ -39,8 +39,7 @@
0
   module AssignmentMethods
0
     def style_like(*styles)
0
       styles.each do |style|
0
- style = style.to_s
0
- sweet_assets[:stylesheets][style.ends_with?('!') ? :bottom : :top] << style.gsub(/!$/, '')
0
+ add_sweet_asset(style.to_s, :stylesheets)
0
       end
0
     end
0
     
0
0
@@ -50,16 +49,31 @@
0
         if 'defaults' == script
0
           SweetAssets.use_primary_javascripts = true
0
         else
0
- sweet_assets[:javascripts][script.ends_with?('!') ? :bottom : :top] << script.gsub(/!$/, '')
0
+ add_sweet_asset(script, :javascripts)
0
         end
0
       end
0
     end
0
     
0
- def sweet_assets
0
- self.is_a?(ActionView::Base) ?
0
- controller.instance_variable_get("@sweet_assets") :
0
- @sweet_assets
0
- end
0
+ protected
0
+
0
+ def add_sweet_asset(asset, collection)
0
+ collection = sweet_assets[collection]
0
+ if asset.ends_with?('!')
0
+ asset.gsub!(/!$/, '')
0
+ collection[:top].delete(asset)
0
+ collection[:bottom] << asset
0
+ else
0
+ unless collection[:bottom].include?(asset)
0
+ collection[:top] << asset
0
+ end
0
+ end
0
+ end
0
+
0
+ def sweet_assets
0
+ self.is_a?(ActionView::Base) ?
0
+ controller.instance_variable_get("@sweet_assets") :
0
+ @sweet_assets
0
+ end
0
   end
0
   
0
   module ClassMethods

Comments

    No one has commented yet.