rocketio 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rocketio/controller/render.rb +22 -4
- data/lib/rocketio/version.rb +1 -1
- data/test/render/layout_test.rb +15 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 942f43f23ee1bc2f6bb2e18dcf097be9dab83ee4
|
4
|
+
data.tar.gz: 1b08c4e3b19666272ca2489f514b069d835e79dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ed0309cf937f7d1828b952ba00781d9aab142f75fb9df192fcb8c17698d9bd0e5d3c9aca341e797de078fcb55f456c9eeccc0101645df61ae926441b974766f
|
7
|
+
data.tar.gz: 84c5a944dcabaa1150817e7e63a0acbb066e292016c27e69a18a70cfca68f0014206b711d97851afc1aff3f4f25b27e63ad4843af822ac9ebfd090f9cf7175e0
|
@@ -77,9 +77,19 @@ module RocketIO
|
|
77
77
|
|
78
78
|
# render a template that yields the given block.
|
79
79
|
# that's it, a layout is a template that yields given string.
|
80
|
+
#
|
81
|
+
# layout can be specified two ways:
|
82
|
+
# - as layout name
|
83
|
+
# - as string
|
84
|
+
#
|
85
|
+
# if both given a ArgumentError error raised.
|
86
|
+
# if :template option given, no layout lookups will occur.
|
87
|
+
#
|
88
|
+
# otherwise...
|
80
89
|
# if no layout name given, it will use the one set at class level.
|
81
90
|
# if no layout set at class level and no layout given, it will raise a RuntimeError.
|
82
|
-
#
|
91
|
+
#
|
92
|
+
# then it will search for given layout between defined ones.
|
83
93
|
# if none found, it will search a file in `path_to_layouts` folder.
|
84
94
|
# it will try each extension registered with effective engine.
|
85
95
|
# if no file found it will raise a TemplateError.
|
@@ -87,11 +97,19 @@ module RocketIO
|
|
87
97
|
# block is required and should return the string to be yielded.
|
88
98
|
#
|
89
99
|
def render_layout template = nil, opts = {}, &block
|
100
|
+
template && opts[:template] && raise(ArgumentError, 'Both layout name and :template option given. Please use either one.')
|
101
|
+
|
90
102
|
opts, template = template, nil if template.is_a?(::Hash)
|
91
|
-
template ||= self.layout
|
92
|
-
template || raise(RocketIO::LayoutError, 'No default layout set and no explicit layout given')
|
93
103
|
engine, engine_opts = resolve_engine(opts)
|
94
|
-
template =
|
104
|
+
template = if template
|
105
|
+
resolve_layout(template, engine)
|
106
|
+
else
|
107
|
+
opts[:template] || begin
|
108
|
+
self.layout || raise(RocketIO::LayoutError, 'No default layout set and no explicit layout given')
|
109
|
+
resolve_layout(self.layout, engine)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
95
113
|
scope = opts.fetch(:scope, self)
|
96
114
|
locals = opts.fetch(:locals, RocketIO::EMPTY_HASH).freeze
|
97
115
|
compile_template(template, engine, engine_opts)
|
data/lib/rocketio/version.rb
CHANGED
data/test/render/layout_test.rb
CHANGED
@@ -100,5 +100,20 @@ spec :Views do
|
|
100
100
|
post
|
101
101
|
assert(last_response).is_ok_with_body('y')
|
102
102
|
end
|
103
|
+
|
104
|
+
it 'accepts layout as :template option' do
|
105
|
+
app mock_controller {
|
106
|
+
def get; render_layout(template: '+<%= yield %>+') {'='}; end
|
107
|
+
}
|
108
|
+
get
|
109
|
+
assert(last_response).is_ok_with_body('+=+')
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'raises ArgumentError if both layout name and :template option given' do
|
113
|
+
app mock_controller {
|
114
|
+
def get; render_layout(:x, template: '+<%= yield %>+') {'='}; end
|
115
|
+
}
|
116
|
+
assert {get}.raise ArgumentError, /both/i
|
117
|
+
end
|
103
118
|
end
|
104
119
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocketio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Slee Woo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -207,8 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
207
|
version: '0'
|
208
208
|
requirements: []
|
209
209
|
rubyforge_project:
|
210
|
-
rubygems_version: 2.5.1
|
210
|
+
rubygems_version: 2.4.5.1
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
|
-
summary: '["rocketio-0.0.
|
213
|
+
summary: '["rocketio-0.0.5", "Simple, fast, scalable web framework for Ruby"]'
|
214
214
|
test_files: []
|