Commit 9e86828
authored
Extend 'LeafRenderer' so that it can render 'Encodable' contexts (#188)
Motivation:
Out of the box, the 'LeafRenderer' offers a base API which can render
Leaf templates to a ByteBuffer. This requires the context to be provided
as a dictionary. With 'ViewRenderer' conformance the 'LeafRenderer' can
render 'View's using an Encodable context.
However, the 'LeafRenderer' can't render templates to a ByteBuffer using
an 'Encodable' context. Since, the 'LeafEncoder' is internal users also
can't encode their context to use the 'base' API.
This functionality is helpful when Leaf is used to render documents
which aren't HTML; such as SVG or XML.
Modifications:
- add an extension to 'LeafRenderer' to render a template at the given
path using an 'Encodable' context
- add a test
Results:
The LeafRenderer can render templates to bytes using Encodable contexts.1 parent 2f02ba9 commit 9e86828
File tree
2 files changed
+56
-3
lines changed- Sources/Leaf
- Tests/LeafTests
2 files changed
+56
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
11 | 27 | | |
12 | 28 | | |
13 | 29 | | |
14 | 30 | | |
15 | 31 | | |
16 | 32 | | |
17 | 33 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 34 | + | |
| 35 | + | |
21 | 36 | | |
22 | 37 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
195 | 233 | | |
196 | 234 | | |
197 | 235 | | |
| |||
0 commit comments