Stencil is a simple and powerful template language for Swift.
2,413
stars
545
commits
Swift
primary language
Dec 22, 2024
updated
Stencil is a simple and powerful template language for Swift. It provides a syntax similar to Django and Mustache. If you're familiar with these, you will feel right at home with Stencil.
There are {{ articles.count }} articles.
<ul>
{% for article in articles %}
<li>{{ article.title }} by {{ article.author }}</li>
{% endfor %}
</ul>
import Stencil
struct Article {
let title: String
let author: String
}
let context = [
"articles": [
Article(title: "Migrating from OCUnit to XCTest", author: "Kyle Fuller"),
Article(title: "Memory Management with ARC", author: "Kyle Fuller"),
]
]
let environment = Environment(loader: FileSystemLoader(paths: ["templates/"]))
let rendered = try environment.renderTemplate(name: "article_list.html", context: context)
print(rendered)
Stencil follows the same philosophy of Django:
If you have a background in programming, or if you’re used to languages which mix programming code directly into HTML, you’ll want to bear in mind that the Django template system is not simply Python embedded into HTML. This is by design: the template system is meant to express presentation, not program logic.
Resources for Stencil template authors to write Stencil templates:
Resources to help you integrate Stencil into a Swift project:
Sourcery, SwiftGen, Kitura, Weaver, Genesis
Stencil is licensed under the BSD license. See LICENSE for more info.
(top 30 of 45)
Swift
75.5%
HTML
15.8%
Ruby
8.4%
Stencil is a simple and powerful template language for Swift.
2,413
stars
545
commits
Swift
primary language
Dec 22, 2024
updated
Stencil is a simple and powerful template language for Swift. It provides a syntax similar to Django and Mustache. If you're familiar with these, you will feel right at home with Stencil.
There are {{ articles.count }} articles.
<ul>
{% for article in articles %}
<li>{{ article.title }} by {{ article.author }}</li>
{% endfor %}
</ul>
import Stencil
struct Article {
let title: String
let author: String
}
let context = [
"articles": [
Article(title: "Migrating from OCUnit to XCTest", author: "Kyle Fuller"),
Article(title: "Memory Management with ARC", author: "Kyle Fuller"),
]
]
let environment = Environment(loader: FileSystemLoader(paths: ["templates/"]))
let rendered = try environment.renderTemplate(name: "article_list.html", context: context)
print(rendered)
Stencil follows the same philosophy of Django:
If you have a background in programming, or if you’re used to languages which mix programming code directly into HTML, you’ll want to bear in mind that the Django template system is not simply Python embedded into HTML. This is by design: the template system is meant to express presentation, not program logic.
Resources for Stencil template authors to write Stencil templates:
Resources to help you integrate Stencil into a Swift project:
Sourcery, SwiftGen, Kitura, Weaver, Genesis
Stencil is licensed under the BSD license. See LICENSE for more info.
(top 30 of 45)
Swift
75.5%
HTML
15.8%
Ruby
8.4%