flame 4.0.6 → 4.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flame/render.rb +23 -9
- data/lib/flame/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10ea7a8158cb464a542f980ccd107c59ba36d5b4
|
4
|
+
data.tar.gz: c93a1fb11b44d074c48aeb16e99fe8e29f3d807c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f971c4a0fa36f66472b062aa35ebf9258af56886aceb8cd965b43e94819c348ce2f870f5322f71c2abcc9dbc061d7e020f5145549920a1ae3edd018b1b348ace
|
7
|
+
data.tar.gz: f2c36b5da0332076131edb4829a1504931cbe092ef0f164124b2ba3a4e91b9d964882bde24bd7fb0108de726b1ff9e7861d7e2bbdf4e3a37f059dabc5d2c0f05
|
data/lib/flame/render.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
require 'tilt'
|
2
4
|
require 'tilt/plain'
|
3
5
|
require 'tilt/erb'
|
@@ -41,6 +43,10 @@ module Flame
|
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
46
|
+
def views_dir
|
47
|
+
@ctrl.config[:views_dir]
|
48
|
+
end
|
49
|
+
|
44
50
|
using GorillaPatch::ModuleExt
|
45
51
|
|
46
52
|
## Compile file with Tilt engine
|
@@ -51,11 +57,12 @@ module Flame
|
|
51
57
|
|
52
58
|
## @todo Add `views_dir` for Application and Controller
|
53
59
|
## @todo Add `layout` method for Controller
|
54
|
-
def find_file(path)
|
60
|
+
def find_file(path, layout: false)
|
55
61
|
## Get full filename
|
62
|
+
dirs = layout ? layout_dirs : controller_dirs
|
56
63
|
Dir[File.join(
|
57
|
-
|
58
|
-
"{#{
|
64
|
+
views_dir,
|
65
|
+
"{#{dirs.join(',')},}",
|
59
66
|
"#{path}.*"
|
60
67
|
)].uniq.find do |file|
|
61
68
|
Tilt[file]
|
@@ -67,18 +74,25 @@ module Flame
|
|
67
74
|
controller_dir_parts = @ctrl.class.underscore.split('/').map do |part|
|
68
75
|
(part.split('_') - %w(controller controllers ctrl)).join('_')
|
69
76
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
77
|
+
controller_dir_parts.map.with_index do |_part, ind|
|
78
|
+
controller_dir_parts[ind..-1].join('/')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def layout_dirs
|
83
|
+
file_dir = Pathname.new(@filename).dirname
|
84
|
+
diff_path = file_dir.relative_path_from Pathname.new(views_dir)
|
85
|
+
diff_parts = diff_path.to_s.split('/')
|
86
|
+
diff_parts.map.with_index do |_part, ind|
|
87
|
+
diff_parts[0..-(ind + 1)].join('/')
|
88
|
+
end
|
75
89
|
end
|
76
90
|
|
77
91
|
## Render the layout with template
|
78
92
|
## @param result [String] result of template rendering
|
79
93
|
## @param cache [Boolean] cache compiles or not
|
80
94
|
def layout_render(result, cache: true)
|
81
|
-
layout_file = find_file(@layout)
|
95
|
+
layout_file = find_file(@layout, layout: true)
|
82
96
|
## Compile layout to hash
|
83
97
|
return result unless layout_file
|
84
98
|
layout =
|
data/lib/flame/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Popov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|