stasis 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,11 +16,30 @@ class Stasis
16
16
  return unless @stasis.path
17
17
  @stasis.action._layout = nil
18
18
  matches = _match_key?(@layouts, @stasis.path)
19
- # Find matching layout with same extension.
20
- matches.each do |(within, layout, non_specific)|
21
- if _within?(within) && File.extname(layout) == File.extname(@stasis.path)
22
- @stasis.action._layout = layout
19
+ # Non-HTML extensions.
20
+ non_html = %w(sass scss less builder coffee yajl)
21
+ # Find matching layout.
22
+ [ :same, :similar ].each do |type|
23
+ matches.each do |(within, layout, non_specific)|
24
+ layout_ext = File.extname(layout)[1..-1]
25
+ path_ext = File.extname(@stasis.path)[1..-1]
26
+
27
+ match =
28
+ case type
29
+ # Same extension?
30
+ when :same then
31
+ layout_ext == path_ext
32
+ # Similar extension?
33
+ when :similar then
34
+ non_html.include?(layout_ext) == non_html.include?(path_ext)
35
+ end
36
+
37
+ # Set layout
38
+ if _within?(within) && match
39
+ @stasis.action._layout = layout
40
+ end
23
41
  end
42
+ break if @stasis.action._layout
24
43
  end
25
44
  # If layout not found, try again without extension requirement for specific layout
26
45
  # definitions only.
data/stasis.gemspec CHANGED
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "stasis"
9
- s.version = '0.1.15'
9
+ s.version = '0.1.16'
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = [ 'Winton Welsh' ]
12
12
  s.email = [ 'mail@wintoni.us' ]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stasis
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 15
10
- version: 0.1.15
9
+ - 16
10
+ version: 0.1.16
11
11
  platform: ruby
12
12
  authors:
13
13
  - Winton Welsh