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.
- data/lib/sprockets/unprocessed_asset.rb +15 -6
- data/lib/turbo-sprockets/version.rb +1 -1
- metadata +1 -1
@@ -1,11 +1,15 @@
|
|
1
1
|
module Sprockets
|
2
2
|
class UnprocessedAsset < AssetWithDependencies
|
3
|
-
def
|
4
|
-
@source.gsub!(/^@import ["']([^"']+)["']
|
3
|
+
def replace_imports(template_with_leading_underscore = true)
|
4
|
+
@source.gsub!(/^@import ["']([^"']+)["'];?/) do |match|
|
5
5
|
begin
|
6
|
-
|
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,
|
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
|
-
#
|
35
|
+
# Include SASS imports
|
31
36
|
if defined?(Sass::Rails::ScssTemplate) && attributes.processors.include?(Sass::Rails::ScssTemplate)
|
32
|
-
|
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)
|