way 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/way.rb +50 -13
- metadata +2 -2
data/lib/way.rb
CHANGED
@@ -1,22 +1,59 @@
|
|
1
1
|
module ActionView
|
2
|
-
PartialRenderer
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
if defined? PartialRenderer
|
3
|
+
PartialRenderer.class_eval do
|
4
|
+
def render_partial
|
5
|
+
locals, view, block = @locals, @view, @block
|
6
|
+
object, as = @object, @variable
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
if !block && (layout = @options[:layout])
|
9
|
+
layout = find_template(layout)
|
10
|
+
end
|
11
|
+
|
12
|
+
object ||= locals[as]
|
13
|
+
locals[as] = object
|
10
14
|
|
11
|
-
|
12
|
-
|
15
|
+
content = @template.render(view, locals) do |*name|
|
16
|
+
view._layout_for(*name, &block)
|
17
|
+
end
|
13
18
|
|
14
|
-
|
15
|
-
|
19
|
+
content = layout.render(view, locals){ content } if layout
|
20
|
+
content << "#{@template.inspect}"
|
16
21
|
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Base.class_eval do
|
26
|
+
def render_partial options = {}
|
27
|
+
local_assigns = options[:locals] || {}
|
17
28
|
|
18
|
-
|
19
|
-
|
29
|
+
case partial_path = options[:partial]
|
30
|
+
when String, Symbol, NilClass
|
31
|
+
if options.has_key?(:collection)
|
32
|
+
render_partial_collection(options)
|
33
|
+
else
|
34
|
+
partial_template = _pick_partial_template(partial_path)
|
35
|
+
partial_content = partial_template.render_partial(self, options[:object], local_assigns)
|
36
|
+
partial_content << "app/views/#{partial_template.to_s}"
|
37
|
+
end
|
38
|
+
when ActionView::Helpers::FormBuilder
|
39
|
+
builder_partial_path = partial_path.class.to_s.demodulize.underscore.sub(/_builder$/, '')
|
40
|
+
local_assigns.merge!(builder_partial_path.to_sym => partial_path)
|
41
|
+
render_partial(:partial => builder_partial_path, :object => options[:object], :locals => local_assigns)
|
42
|
+
else
|
43
|
+
if Array === partial_path ||
|
44
|
+
(defined?(ActiveRecord) &&
|
45
|
+
(ActiveRecord::Associations::AssociationCollection === partial_path ||
|
46
|
+
ActiveRecord::NamedScope::Scope === partial_path))
|
47
|
+
render_partial_collection(options.except(:partial).merge(:collection => partial_path))
|
48
|
+
else
|
49
|
+
object = partial_path
|
50
|
+
render_partial(
|
51
|
+
:partial => ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path),
|
52
|
+
:object => object,
|
53
|
+
:locals => local_assigns
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
20
57
|
end
|
21
58
|
end
|
22
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: way
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: calebcohoon@gmail.com
|