run_simple_render 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +60 -10
- data/lib/run_simple_render/version.rb +1 -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: 833966d0efcb0d59e0a39cdc6eb46c2206083e3f
|
4
|
+
data.tar.gz: cd82ada654c19361de37630466a6e45dffc9b2bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8221a3cb304eb0dbd2a8570b8481cb0ad476e527039dbd76114e072489dad501796a4b43ebecac4918f261a6513fe1d0620e1819522df0e679be777294e55442
|
7
|
+
data.tar.gz: bf14cf69fa78874a7c7018a5b6df2eba9b7f5081ac107b9e269247f25fe2af36a9cd8c60e0e8d20bfca7c66459a5f8324fae52d9cbb703ae9cb7fca82f73d2ba
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# RunSimpleRender
|
2
2
|
|
3
|
-
|
3
|
+
Simple approach to have an powerful presentation
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
|
10
|
-
gem 'run_simple_render'
|
11
|
-
|
9
|
+
|
10
|
+
ruby gem 'run_simple_render'
|
11
|
+
|
12
12
|
|
13
13
|
And then execute:
|
14
14
|
|
@@ -20,12 +20,62 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
A. Include RunSimpleRender in the model
|
24
|
+
|
25
|
+
|
26
|
+
class User < ActiveRecord::Base
|
27
|
+
include RunSimpleRender
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
B. Create your model views under a folder called renditions
|
32
|
+
|
33
|
+
|
34
|
+
$ /views/renditions/[modelname]/
|
35
|
+
|
36
|
+
|
37
|
+
ex. /views/renditions/user/default.html.erb:
|
38
|
+
|
39
|
+
|
40
|
+
Name: <%=obj.last_name %>, <%obj.first_name%>
|
41
|
+
|
42
|
+
|
43
|
+
ex. /views/renditions/user/email.html.erb:
|
44
|
+
|
45
|
+
|
46
|
+
Email: <%=obj.email %>
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
C. Render the appropriate view as needed and were needed
|
51
|
+
|
52
|
+
@usr = User.find(1)
|
53
|
+
|
54
|
+
@usr.render #Name: Louis, Joe
|
55
|
+
|
56
|
+
@usr.render(:email) #Email: joe@louis.com
|
57
|
+
|
58
|
+
|
59
|
+
## More
|
60
|
+
|
61
|
+
You can also call relate models
|
62
|
+
|
63
|
+
@usr = User.find(1)
|
64
|
+
|
65
|
+
@usr.company.render(:short_description)
|
66
|
+
|
67
|
+
Or render collection from the view ex. /views/renditions/company/all_users.html.erb:
|
68
|
+
|
69
|
+
Company: <%= obj.name %>
|
70
|
+
|
71
|
+
<p>Users</p>
|
72
|
+
<ul>
|
73
|
+
<% obj.users.each |u| %>
|
74
|
+
<li><%= u.render %> [ <%= u.email %>]</li>
|
75
|
+
<% end %>
|
76
|
+
</ul>
|
77
|
+
|
24
78
|
|
25
79
|
## Contributing
|
26
80
|
|
27
|
-
|
28
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
-
5. Create a new Pull Request
|
81
|
+
Coming soon!!
|