active_path 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -24
- data/lib/active_path/helpers/rendering_helper.rb +2 -7
- data/lib/active_path/renderer/partial_renderer.rb +22 -16
- data/lib/active_path/version.rb +1 -1
- data/lib/active_path.rb +0 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11521118a9c1286cbef1df712f650ecad8e146c8
|
4
|
+
data.tar.gz: c669aa1ecef84937035bba5a4a8ed457671ee7a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6748d8386d87b2d375110dc783a02dd38904fedfe7d383631a820cbfec33be4faf45f0da1a9d5bcaf72ec7542ccce781eea389d4361e9e8cc7213bf195ed8422
|
7
|
+
data.tar.gz: '048da2e8401bb24de04b27d6a9f280dd6cbfa33f4780ba7dfbca9da86d4493ae419bd4f05959149c6f1b7ef8f83aad396333c650047873b8c004479ac12ba5f2'
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
View injection and path hints for Rails 5.
|
3
3
|
|
4
4
|
|
5
|
-
##Installation
|
5
|
+
## Installation
|
6
6
|
|
7
7
|
Add to your Gemfile:
|
8
8
|
|
@@ -23,9 +23,9 @@ end
|
|
23
23
|
```
|
24
24
|
|
25
25
|
|
26
|
-
##Configuration
|
26
|
+
## Configuration
|
27
27
|
|
28
|
-
**
|
28
|
+
**View injection:**
|
29
29
|
|
30
30
|
```ruby
|
31
31
|
|
@@ -43,26 +43,6 @@ The above example assumes your application renders a partial called 'page_conten
|
|
43
43
|
|
44
44
|
Your partial will have the same local parameters access as the prepended partial.
|
45
45
|
|
46
|
-
--
|
47
|
-
|
48
|
-
**More ways to inject content into views**
|
49
|
-
|
50
|
-
```ruby
|
51
|
-
|
52
|
-
ActivePath.configure do |config|
|
53
|
-
|
54
|
-
...
|
55
|
-
|
56
|
-
config.partials.prepend('page_content').with(
|
57
|
-
partial: 'example/test',
|
58
|
-
helper: ExampleHelper
|
59
|
-
)
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
```
|
64
|
-
|
65
|
-
The above example is similar to the first but also adds your helper to the view.
|
66
46
|
|
67
47
|
--
|
68
48
|
|
@@ -81,6 +61,6 @@ end
|
|
81
61
|
|
82
62
|
```
|
83
63
|
|
84
|
-
|
64
|
+
HTML comments are added before and after each partial.
|
85
65
|
|
86
66
|
Feel free to [submit issues](https://github.com/ryaan-anthony/active-path/issues) or [help make it better](https://github.com/ryaan-anthony/active-path/pulls).
|
@@ -3,17 +3,12 @@ module ActivePath
|
|
3
3
|
module Helpers
|
4
4
|
module RenderingHelper
|
5
5
|
extend ActionView::Helpers::RenderingHelper
|
6
|
+
# Delegate rendering to the activepath renderer
|
6
7
|
def render(options = {}, locals = {}, &block)
|
7
|
-
|
8
|
+
Renderer::PartialRenderer.new(self, options).render do
|
8
9
|
super
|
9
10
|
end
|
10
11
|
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def active_path_renderer(options, locals)
|
15
|
-
Renderer::PartialRenderer.new(options, locals)
|
16
|
-
end
|
17
12
|
end
|
18
13
|
end
|
19
14
|
end
|
@@ -1,26 +1,22 @@
|
|
1
1
|
module ActivePath
|
2
2
|
module Renderer
|
3
3
|
class PartialRenderer
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :context, :options
|
5
5
|
|
6
|
-
def initialize(
|
6
|
+
def initialize(context, options = {})
|
7
|
+
@context = context
|
7
8
|
@options = options
|
8
|
-
@locals = locals
|
9
9
|
end
|
10
10
|
|
11
11
|
def render
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def after
|
23
|
-
partials.append(partial).attachments
|
12
|
+
output_buffer = yield
|
13
|
+
partials.prepend(partial_name).attachments.each do |attachment|
|
14
|
+
output_buffer.prepend(render_attachment(attachment))
|
15
|
+
end
|
16
|
+
partials.append(partial_name).attachments.each do |attachment|
|
17
|
+
output_buffer.concat(render_attachment(attachment))
|
18
|
+
end
|
19
|
+
output_buffer
|
24
20
|
end
|
25
21
|
|
26
22
|
private
|
@@ -29,9 +25,19 @@ module ActivePath
|
|
29
25
|
ActivePath.config.partials
|
30
26
|
end
|
31
27
|
|
32
|
-
def
|
28
|
+
def partial_name
|
33
29
|
options.is_a?(Hash) ? options[:partial] : options.to_s
|
34
30
|
end
|
31
|
+
|
32
|
+
def render_attachment(attachment)
|
33
|
+
options_hash = attachment_options(attachment)
|
34
|
+
context.render(options_hash)
|
35
|
+
end
|
36
|
+
|
37
|
+
def attachment_options(attachment)
|
38
|
+
hash = { partial: attachment }
|
39
|
+
options.is_a?(Hash) ? options.merge(hash) : hash
|
40
|
+
end
|
35
41
|
end
|
36
42
|
end
|
37
43
|
end
|
data/lib/active_path/version.rb
CHANGED
data/lib/active_path.rb
CHANGED