Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

problem resolved with relative URL rewriter - was returning nothing i…

…f no relative urls to rewrite

git-svn-id: http://bundle-fu.googlecode.com/svn/trunk@84 1db77ec0-6337-0410-9320-454da9aca44f
  • Loading branch information...
commit c6783a5cc2a5dab1f8b8d06d02cbfb9de199980f 1 parent c13f84b
timcharper authored
View
58 README
@@ -17,64 +17,16 @@ Install this plugin
Put the following around your stylesheets/javascripts (note it works with any method of including assets!):
<% bundle do %>
+ ...
<%= javascript_include_tag "prototype" %>
<%= stylesheet_link_tag "basic.css" %>
<%= calendar_date_select_includes params[:style] %>
<script src="javascripts/application.js" type="text/javascript"></script>
+ ...
<% end %>
That's it!
-----------------------------------------------------
-GOTCHAS
-----------------------------------------------------
-
- * All content inside of bundle do will be replaced with a single js and css include statement. Any other content will be lost. Be sure to only put css / js includes inside of the block.
- * Scripts / stylesheets are detected by parsing the output and looking for include files. Comments are ignored, so if you comment out a stylesheet like this:
- <% bundle do %>
- <%= javascript_include_tag "prototype" %>
- <!-- <%= stylesheet_link_tag "basic" %> -->
- <%= calendar_date_select_includes params[:style] %>
- <script src="javascripts/application.js" type="text/javascript"></script>
- <% end %>
-
- The comment will be ignored and the css file will be bundled anyways. If you need to comment out
- a css file to perform an ie6 hack, put it outside the bundle block.
- <% bundle do %>
- <%= javascript_include_tag :defaults %>
- <%= stylesheet_link_tag "basic" %>
- <% end %>
- <!--[if lt IE 7.]>
- <%= stylesheet_link_tag "ie6fix" %>
- <![endif]-->
-
- (it shouldn't be bundled anyways, since it's conditionally loaded)
- * Relative paths in CSS may be disrupted.
- If you're css depends on relative paths, they may be disrupted since they will be loaded likely
- from a different directory. You can solve this by changing the directory a bundle is loaded from.
-
- <% bundle :css_path => "/stylesheets/", :js_path => "/javascripts/" do %>
- <%= javascript_include_tag :defaults %>
- <%= stylesheet_link_tag "basic" %>
- <% end %>
-
- * Conditionally loaded css files and javascript files gotcha:
- Consider the following
- <% bundle do %>
- <%= javascript_include_tag :defaults %>
- <%= stylesheet_link_tag "#{@theme || 'blue'}_color_scheme" %>
- <% end %>
-
- On development, this will work fine. The bundle.css file will be regenerated everytime the theme changes.
- However, on production, this will be effectively ignored, as the content is only regenerated once per
- server instance. To remedy this, change the name parameter:
- <% bundle :name => "bundle_#{@theme || 'blue'}" do %>
- <%= javascript_include_tag :defaults %>
- <%= stylesheet_link_tag "#{@theme || 'blue'}_color_scheme" %>
- <% end %>
-
- bundle_fu will generate a different bundle file for each instance of @theme, only once!
-
-Author:
-Tim C. Harper - irb(main):001:0> ( 'tim_see_harperATgmail._see_om'.gsub('_see_', 'c').gsub('AT', '@') )
-
+More info:
+
+http://code.google.com/p/bundle-fu/
View
1  lib/bundle_fu/css_url_rewriter.rb
@@ -35,6 +35,7 @@ def rewrite_relative_path(source_filename, relative_url)
# url('/images/active_scaffold/default/add.gif');
def rewrite_urls(filename, content)
content.gsub!(/url *\(([^\)]+)\)/) { "url(#{rewrite_relative_path(filename, $1)})" }
+ content
end
end
View
6 test/functional/css_bundle_test.rb
@@ -19,4 +19,10 @@ def test__bundle_css_file__should_rewrite_relatiave_path
assert_match("background-image: url(/images/background.gif)", bundled_css)
assert_match("background-image: url(/images/groovy/background_2.gif)", bundled_css)
end
+
+ def test__bundle_css_files__no_images__should_return_content
+ bundled_css = BundleFu.bundle_css_files(["/stylesheets/css_1.css"])
+ assert_match("css_1 { }", bundled_css)
+
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.