feat(variable): Allow Swift type introspection

This commit is contained in:
Kyle Fuller
2016-11-28 06:13:46 +00:00
parent 9af9cf4005
commit 38d7ec87f6
7 changed files with 57 additions and 12 deletions

View File

@@ -17,15 +17,20 @@ feel right at home with Stencil.
.. code-block:: swift
struct Article {
let title: String
let author: String
}
let context = Context(dictionary: [
"articles": [
[ "title": "Migrating from OCUnit to XCTest", "author": "Kyle Fuller" ],
[ "title": "Memory Management with ARC", "author": "Kyle Fuller" ],
Article(title: "Migrating from OCUnit to XCTest", author: "Kyle Fuller"),
Article(title: "Memory Management with ARC", author: "Kyle Fuller"),
]
])
do {
let template = try Template(named: "template.stencil")
let template = try Template(named: "template.html")
let rendered = try template.render(context)
print(rendered)
} catch {

View File

@@ -22,6 +22,7 @@ following lookup:
- Dictionary lookup
- Array lookup (first, last, count, index)
- Key value coding lookup
- Type introspection
For example, if `people` was an array: