run_simple_render 0.1.2 → 0.1.3
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 +18 -4
- data/lib/run_simple_render/version.rb +1 -1
- data/lib/run_simple_render.rb +2 -2
- 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: 1716e5a1f6d3f78d56fd57dc7997b1c3b86be355
|
4
|
+
data.tar.gz: 1438daf4426e5041b75d9e170295a18b32bbe461
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 363ea4b56d72ad8169af5179fb5942b924ea78056bd8bd618c59838ad6e1d55a4f0d26683371c78b130faa5a28cb23a122a4eb217eeb5bf19e8e4434798b986d
|
7
|
+
data.tar.gz: 1a49d81d5da075ca2757e163e252dbcf51eb3bd06fa47d40c73a2dc7342c835883d8157fac474d2f31df265e77c9a1943d571053cb3fab1c7235e5a58362b646
|
data/README.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# RunSimpleRender
|
2
2
|
|
3
|
-
Simple approach to have
|
3
|
+
Simple approach to have a more powerful presentation in rails.
|
4
|
+
|
5
|
+
The idea behind this gem is to be able to tie models to the appropriate
|
6
|
+
views for the maximun reusability while **avoiding**:
|
7
|
+
|
8
|
+
a. helpers with inline html
|
9
|
+
|
10
|
+
b: creation of additional classes (with more html within the methods)
|
11
|
+
|
12
|
+
c. bloating the models with presentation methods (bad practice)
|
13
|
+
|
14
|
+
d. a learning curve (this is extremely easy to use)
|
15
|
+
|
4
16
|
|
5
17
|
## Installation
|
6
18
|
|
@@ -31,7 +43,7 @@ A. Include RunSimpleRender in the model
|
|
31
43
|
B. Create your model views under a folder called renditions
|
32
44
|
|
33
45
|
|
34
|
-
|
46
|
+
$ /views/renditions/[modelname]/
|
35
47
|
|
36
48
|
|
37
49
|
ex. /views/renditions/user/default.html.erb:
|
@@ -58,13 +70,13 @@ C. Render the appropriate view as needed and were needed
|
|
58
70
|
|
59
71
|
## More
|
60
72
|
|
61
|
-
You can also call
|
73
|
+
You can also call related models
|
62
74
|
|
63
75
|
@usr = User.find(1)
|
64
76
|
|
65
77
|
@usr.company.render(:short_description)
|
66
78
|
|
67
|
-
Or render collection from the view ex. /views/renditions/company/all_users.html.erb:
|
79
|
+
Or render a collection from the view ex. /views/renditions/company/all_users.html.erb:
|
68
80
|
|
69
81
|
Company: <%= obj.name %>
|
70
82
|
|
@@ -79,3 +91,5 @@ Or render collection from the view ex. /views/renditions/company/all_users.html
|
|
79
91
|
## Contributing
|
80
92
|
|
81
93
|
Coming soon!!
|
94
|
+
|
95
|
+
|
data/lib/run_simple_render.rb
CHANGED
@@ -15,7 +15,7 @@ module RunSimpleRender
|
|
15
15
|
end
|
16
16
|
template_path = template_path.underscore
|
17
17
|
begin
|
18
|
-
ApplicationController.new.render_to_string(template: template_path, locals:{obj: self, args: args}, layout: false).html_safe
|
18
|
+
ApplicationController.new.render_to_string(template: template_path, locals:{ obj: self, args: args}, layout: false).html_safe
|
19
19
|
#Call the parent if not let it fail
|
20
20
|
rescue ActionView::MissingTemplate
|
21
21
|
puts "Warning: [#{self.class.name}] did not have #{template_path} defined. Trying the parent [#{self.class.base_class.name}]"
|
@@ -23,7 +23,7 @@ module RunSimpleRender
|
|
23
23
|
template_path = template_path.split('/')
|
24
24
|
template_path.delete_at(2)
|
25
25
|
template_path = template_path.join('/')
|
26
|
-
ApplicationController.new.render_to_string(template: template_path,locals:{obj: self}, layout: false).html_safe
|
26
|
+
ApplicationController.new.render_to_string(template: template_path,locals:{ obj: self}, layout: false).html_safe
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|