Skip to content

Commit f48bcb2

Browse files
committed
Merge branch 'alternate-filenames' into future
* alternate-filenames: Be more flexible about where we can find the split-point
2 parents f15fbfa + d59ec0a commit f48bcb2

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ You also need to remember to add those new files to the asset pipeline, so they
4444
Here is a checklist of requirements for your split stylesheet:
4545

4646
1. It needs to have different filename than orginal, e.g. `original_stylesheet_split2` or `application_split2`
47-
2. It needs to have `.split2` as the terminal file extension, e.g. `.css.split2` or `.css.sass.split2`
48-
3. It needs to include the content of the orginal stylesheet, e.g. through `//= include 'application'`
47+
2. It needs to have `.split2` as a file extension, e.g. `.css.split2`, `.css.sass.split2`, or `.css.split2.erb`
48+
3. It needs to include the content of the orginal stylesheet, e.g. through `//= include 'application'` or `<%= environment.find_asset('application') %>`
4949
4. It needs to be added to list of precompiled assets
5050

5151

lib/css_splitter/sprockets_engine.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ def prepare
1111
end
1212

1313
def evaluate(scope, locals, &block)
14-
split = scope.pathname.extname =~ /(\d+)$/ && $1 || 0 # determine which is the current split (e.g. split2, split3)
15-
CssSplitter::Splitter.split_string data, split.to_i
14+
# determine which is the current split (e.g. split2, split3)
15+
split = if scope.pathname.extname =~ /(\d+)$/; $1
16+
elsif scope.pathname.basename.to_s =~ /_split(\d+)\.css/; $1
17+
else 2
18+
end
19+
CssSplitter::Splitter.split_string(data, split.to_i)
1620
end
1721
end
1822

19-
end
23+
end

0 commit comments

Comments
 (0)