turbo-sprockets-rails3 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,15 @@
1
1
  module Sprockets
2
2
  class UnprocessedAsset < AssetWithDependencies
3
- def replace_scss_imports
4
- @source.gsub!(/^@import ["']([^"']+)["']/) do |match|
3
+ def replace_imports(template_with_leading_underscore = true)
4
+ @source.gsub!(/^@import ["']([^"']+)["'];?/) do |match|
5
5
  begin
6
- template = "_#{$1}"
6
+ if template_with_leading_underscore
7
+ template = "_#{$1}"
8
+ else
9
+ template = $1
10
+ end
7
11
  pathname = @environment.resolve(template)
8
- asset = UnprocessedAsset.new @environment, '_changeme2', pathname
12
+ asset = UnprocessedAsset.new @environment, template, pathname
9
13
  # Replace imported template with the unprocessed asset contents.
10
14
  asset.to_s
11
15
  rescue Sprockets::FileNotFound
@@ -14,6 +18,7 @@ module Sprockets
14
18
  end
15
19
  end
16
20
 
21
+
17
22
  def initialize(environment, logical_path, pathname)
18
23
  super
19
24
 
@@ -27,9 +32,13 @@ module Sprockets
27
32
 
28
33
  @source = context.evaluate(pathname, :processors => processors)
29
34
 
30
- # Manually include files that are @imported from SCSS
35
+ # Include SASS imports
31
36
  if defined?(Sass::Rails::ScssTemplate) && attributes.processors.include?(Sass::Rails::ScssTemplate)
32
- replace_scss_imports
37
+ replace_imports(true) # Template has leading underscore
38
+ end
39
+ # Include Less imports
40
+ if defined?(Less::Rails::LessTemplate) && attributes.processors.include?(Less::Rails::LessTemplate)
41
+ replace_imports(false) # Template has no leading underscore
33
42
  end
34
43
 
35
44
  build_required_assets(environment, context, :process => false)
@@ -1,3 +1,3 @@
1
1
  module TurboSprockets
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo-sprockets-rails3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: