rack-app-front_end 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rack/app/front_end/instance_methods.rb +7 -3
- data/lib/rack/app/front_end/template.rb +27 -6
- metadata +1 -2
- data/spike/test.html.erb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5983723b1ed5893aa432c049e76c58734f9113b
|
4
|
+
data.tar.gz: 3ddce6ab78b7939cf2e5fe9c55b99887926918ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69ee00d52045b883dbea6d5cb38af91b2ce1c6134b97da4d2d526c73cfd63af75f15662a3949b89cc839a8789ed21a0a80668c5fe37e6a11623b193ae32c7f9b
|
7
|
+
data.tar.gz: 0b868ba5876ef8c515b2f5d1525d4225b1b274e1599e9a58f0ad3b9a7a2ceec5fcfa46927946780b96641c2c4db0a4a155fa7b4a51dcc750a2b9837dd634e0ee
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.13.0
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module Rack::App::FrontEnd::InstanceMethods
|
2
2
|
|
3
|
-
def render(template_path)
|
3
|
+
def render(template_path, *args, &block)
|
4
4
|
full_path = Rack::App::Utils.expand_path(template_path)
|
5
|
-
template = Rack::App::FrontEnd::Template.new(full_path, self.class)
|
6
|
-
return template.render(self)
|
5
|
+
template = Rack::App::FrontEnd::Template.new(full_path, __runtime_properties__[:layout], self.class)
|
6
|
+
return template.render(self, *args, &block)
|
7
|
+
end
|
8
|
+
|
9
|
+
def __runtime_properties__
|
10
|
+
@__runtime_properties__ ||= {}
|
7
11
|
end
|
8
12
|
|
9
13
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'tilt'
|
2
2
|
class Rack::App::FrontEnd::Template
|
3
|
+
NO_LAYOUT_KEYWORD = :none
|
3
4
|
|
4
5
|
require 'rack/app/front_end/template/default_layout'
|
5
6
|
|
@@ -13,14 +14,16 @@ class Rack::App::FrontEnd::Template
|
|
13
14
|
|
14
15
|
protected
|
15
16
|
|
16
|
-
def initialize(
|
17
|
-
@file_path =
|
17
|
+
def initialize(template_path, layout, klass)
|
18
|
+
@file_path = template_path
|
19
|
+
@layout = layout
|
18
20
|
@class = klass
|
19
21
|
end
|
20
22
|
|
21
23
|
def render_result(scope, *args, &block)
|
22
24
|
return Rack::App::File::Streamer.new(@file_path) unless it_is_a_template?
|
23
|
-
scope
|
25
|
+
extend_with_helpers(scope)
|
26
|
+
block_layouts_for(scope)
|
24
27
|
layout.render(scope, *args) { template.render(scope, *args, &block) }
|
25
28
|
end
|
26
29
|
|
@@ -33,13 +36,31 @@ class Rack::App::FrontEnd::Template
|
|
33
36
|
end
|
34
37
|
|
35
38
|
def layout
|
36
|
-
return DefaultLayout if
|
37
|
-
|
38
|
-
get_template(
|
39
|
+
return DefaultLayout if use_default_layout?
|
40
|
+
|
41
|
+
get_template(layout_path)
|
42
|
+
end
|
43
|
+
|
44
|
+
def layout_path
|
45
|
+
return @class.layout
|
46
|
+
end
|
47
|
+
|
48
|
+
def use_default_layout?
|
49
|
+
(@layout == NO_LAYOUT_KEYWORD) or
|
50
|
+
(@class.respond_to?(:layout) and @class.layout.nil?) or
|
51
|
+
(@file_path =~ /^#{Regexp.escape(Rack::App::Utils.namespace_folder(layout_path))}/)
|
39
52
|
end
|
40
53
|
|
41
54
|
def get_template(file_path)
|
42
55
|
self.class.cache.fetch(file_path) { Tilt.new(file_path) }
|
43
56
|
end
|
44
57
|
|
58
|
+
def extend_with_helpers(scope)
|
59
|
+
scope.extend(@class.helpers) if @class.respond_to?(:helpers)
|
60
|
+
end
|
61
|
+
|
62
|
+
def block_layouts_for(scope)
|
63
|
+
scope.__runtime_properties__[:layout]= NO_LAYOUT_KEYWORD
|
64
|
+
end
|
65
|
+
|
45
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-app-front_end
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
@@ -106,7 +106,6 @@ files:
|
|
106
106
|
- lib/rack/app/front_end/template/default_layout.rb
|
107
107
|
- lib/rack/app/front_end/version.rb
|
108
108
|
- rack-app-front_end.gemspec
|
109
|
-
- spike/test.html.erb
|
110
109
|
homepage: http://www.rack-app.com/
|
111
110
|
licenses:
|
112
111
|
- Apache License 2.0
|
data/spike/test.html.erb
DELETED