public
Description: Merb More: The Full Stack. Take what you need; leave what you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-more.git
Search Repo:
Fixed failing specs - include_required_js/css now include a file only once
fabien (author)
Mon Jun 16 05:45:04 -0700 2008
commit  17e2c02a2e651902f3a4176e106832646607b728
tree    a8a0bbd1eb66eb508e64df207a96e0a591e52cfc
parent  391344158933397e4d67b00a4e54fed730cb63ee
...
42
43
44
45
 
46
47
48
...
42
43
44
 
45
46
47
48
0
@@ -42,7 +42,7 @@ module Merb
0
       def asset_path(asset_type, filename, local_path = false)
0
         filename = filename.to_s
0
         if filename !~ /#{'\\' + ASSET_FILE_EXTENSIONS[asset_type]}\Z/ && filename.index('?').nil?
0
- filename << ASSET_FILE_EXTENSIONS[asset_type]
0
+ filename = "#{filename}#{ASSET_FILE_EXTENSIONS[asset_type]}" # don't modify receiver
0
         end
0
         if filename !~ %r{^https?://}
0
           filename = "/#{asset_type}s/#{filename}"
...
346
347
348
 
349
350
351
 
 
352
353
 
354
 
 
355
356
357
...
385
386
387
 
388
389
390
 
 
391
392
 
393
 
 
394
395
396
...
346
347
348
349
350
 
 
351
352
353
 
354
355
356
357
358
359
360
...
388
389
390
391
392
 
 
393
394
395
 
396
397
398
399
400
401
402
0
@@ -346,12 +346,15 @@ module Merb
0
     #
0
     def include_required_js(options = {})
0
       return '' if @required_js.nil? || @required_js.empty?
0
+ seen = []
0
       @required_js.map do |req_js|
0
- if req_js.last.is_a?(Hash)
0
- js_include_tag(*(req_js[0..-2] + [options.merge(req_js.last)]))
0
+ js_files, js_options = if req_js.last.is_a?(Hash)
0
+ [req_js[0..-2], options.merge(req_js.last)]
0
         else
0
- js_include_tag(*(req_js + [options]))
0
+ [req_js, options]
0
         end
0
+ seen += (includes = js_files - seen)
0
+ js_include_tag(*(includes + [js_options]))
0
       end.join
0
     end
0
 
0
@@ -385,12 +388,15 @@ module Merb
0
     #
0
     def include_required_css(options = {})
0
       return '' if @required_css.nil? || @required_css.empty?
0
+ seen = []
0
       @required_css.map do |req_css|
0
- if req_css.last.is_a?(Hash)
0
- css_include_tag(*(req_css[0..-2] + [options.merge(req_css.last)]))
0
+ css_files, css_options = if req_css.last.is_a?(Hash)
0
+ [req_css[0..-2], options.merge(req_css.last)]
0
         else
0
- css_include_tag(*(req_css + [options]))
0
+ [req_css, options]
0
         end
0
+ seen += (includes = css_files - seen)
0
+ css_include_tag(*(includes + [css_options]))
0
       end.join
0
     end
0
 

Comments

    No one has commented yet.