end_view 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -23
- data/lib/end_view.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: 3ca9c4f5f9b15471377b2a14e38769126f23a3b0
|
4
|
+
data.tar.gz: 7a0b708d6d24fbc83254e43e1d720ad90bab9341
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74c7f9dc759075b7c66fcb3b955eac6548d4127763a5fb26984fc2d14951d7bcf3ed917a33b99b514dc4067763f8ea75d0483468365a20e45b81dba3f7ac7917
|
7
|
+
data.tar.gz: 5ecc6e8025ed52148f30a14a4f3bea3475ca36085693f6f798f81b888b928d0f1c34c48d2290427bb6226d9152737ebd99c219c34ae9f6bb7a3924983dbb1e75
|
data/README.md
CHANGED
@@ -45,6 +45,34 @@ __END__
|
|
45
45
|
Howdy <%= my_method %>
|
46
46
|
```
|
47
47
|
|
48
|
+
### Template Engine
|
49
|
+
|
50
|
+
By default Tilt's ERB template engine is used, but alternative engines can be passed in:
|
51
|
+
|
52
|
+
``` ruby
|
53
|
+
require 'tilt/haml'
|
54
|
+
|
55
|
+
class Ham
|
56
|
+
include EndView.new(__FILE__, Tilt::HamlTemplate)
|
57
|
+
|
58
|
+
def my_method
|
59
|
+
'Heya'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
Ham.new.render # <h1>Heya</h1>
|
64
|
+
|
65
|
+
__END__
|
66
|
+
|
67
|
+
%h1= my_method
|
68
|
+
```
|
69
|
+
|
70
|
+
To change the default engine:
|
71
|
+
|
72
|
+
``` ruby
|
73
|
+
EndView.default_engine = Tilt::LiquidTemplate
|
74
|
+
```
|
75
|
+
|
48
76
|
### Layouts
|
49
77
|
|
50
78
|
For template engines that support it, view models can passed blocks:
|
@@ -108,32 +136,12 @@ __END__
|
|
108
136
|
The <%= my_method %> is too big!
|
109
137
|
```
|
110
138
|
|
111
|
-
###
|
139
|
+
### locals
|
112
140
|
|
113
|
-
|
141
|
+
Locals can be passed into the render method that override the view models:
|
114
142
|
|
115
143
|
``` ruby
|
116
|
-
|
117
|
-
|
118
|
-
class Ham
|
119
|
-
include EndView.new(__FILE__, Tilt::HamlTemplate)
|
120
|
-
|
121
|
-
def my_method
|
122
|
-
'Heya'
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
Ham.new.render # <h1>Heya</h1>
|
127
|
-
|
128
|
-
__END__
|
129
|
-
|
130
|
-
%h1= my_method
|
131
|
-
```
|
132
|
-
|
133
|
-
To change the default engine:
|
134
|
-
|
135
|
-
``` ruby
|
136
|
-
EndView.default_engine = Tilt::LiquidTemplate
|
144
|
+
Foo.new.render(my_method: 'Stranger') # Hello Stranger
|
137
145
|
```
|
138
146
|
|
139
147
|
## Installation
|
data/lib/end_view.rb
CHANGED
@@ -44,8 +44,8 @@ class EndView < Module
|
|
44
44
|
end
|
45
45
|
|
46
46
|
module Methods
|
47
|
-
def render(&b)
|
48
|
-
rendered_template = template.render(self, &b)
|
47
|
+
def render(*args, &b)
|
48
|
+
rendered_template = template.render(self, *args, &b)
|
49
49
|
layout ? layout.render { rendered_template } : rendered_template
|
50
50
|
end
|
51
51
|
end
|