Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stencilproject/Stencil
Stencil is a simple and powerful template language for Swift.
https://github.com/stencilproject/Stencil
Last synced: about 1 month ago
JSON representation
Stencil is a simple and powerful template language for Swift.
- Host: GitHub
- URL: https://github.com/stencilproject/Stencil
- Owner: stencilproject
- License: bsd-2-clause
- Created: 2014-10-23T11:29:09.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-04-11T00:17:33.000Z (8 months ago)
- Last Synced: 2024-05-19T08:06:41.982Z (7 months ago)
- Language: Swift
- Homepage: https://stencil.fuller.li
- Size: 874 KB
- Stars: 2,317
- Watchers: 34
- Forks: 221
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-swift - Stencil - Simple and powerful template language. (Libs / UI)
- awesome-swift - Stencil - Simple and powerful template language. (Libs / UI)
- awesome-swift - Stencil - Stencil is a simple and powerful template language for Swift. ` π 3 months ago` (UI [π](#readme))
- awesome-swift - Stencil - Simple and powerful template language. (Libs / UI)
README
# Stencil
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.## Example
```html+django
There are {{ articles.count }} articles.
- {{ article.title }} by {{ article.author }}
{% for article in articles %}
{% endfor %}
```
```swift
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)
```
## Philosophy
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.
## The User Guide
Resources for Stencil template authors to write Stencil templates:
- [Language overview](http://stencil.fuller.li/en/latest/templates.html)
- [Built-in template tags and filters](http://stencil.fuller.li/en/latest/builtins.html)
Resources to help you integrate Stencil into a Swift project:
- [Installation](http://stencil.fuller.li/en/latest/installation.html)
- [Getting Started](http://stencil.fuller.li/en/latest/getting-started.html)
- [API Reference](http://stencil.fuller.li/en/latest/api.html)
- [Custom Template Tags and Filters](http://stencil.fuller.li/en/latest/custom-template-tags-and-filters.html)
## Projects that use Stencil
[Sourcery](https://github.com/krzysztofzablocki/Sourcery),
[SwiftGen](https://github.com/SwiftGen/SwiftGen),
[Kitura](https://github.com/IBM-Swift/Kitura),
[Weaver](https://github.com/scribd/Weaver),
[Genesis](https://github.com/yonaskolb/Genesis)
## License
Stencil is licensed under the BSD license. See [LICENSE](LICENSE) for more
info.