T. R. Bernstein 02f61d55a4
Some checks failed
Danger / Danger Check (push) Has been cancelled
Lint Cocoapods / Pod Lint (push) Has been cancelled
SwiftLint / SwiftLint (push) Has been cancelled
Test SPM / Test SPM Linux (push) Has been cancelled
Test SPM / Test SPM macOS (push) Has been cancelled
Publish on Tag / GitHub Release (push) Has been cancelled
chore: release 0.15.2
2025-09-30 23:14:57 +02:00
2025-09-30 23:12:59 +02:00
2025-09-30 23:14:57 +02:00
2025-09-30 23:12:59 +02:00
2022-07-27 02:09:52 +02:00
2022-07-27 02:56:21 +02:00
2025-09-30 23:14:57 +02:00
2025-09-30 23:12:59 +02:00
2025-09-30 23:12:59 +02:00
2025-09-30 23:12:59 +02:00
2025-09-30 23:12:59 +02:00
2022-07-28 03:15:54 +02:00
2025-09-30 23:14:57 +02:00

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

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)

Philosophy

Stencil follows the same philosophy of Django:

If you have a background in programming, or if youre used to languages which mix programming code directly into HTML, youll 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:

Resources to help you integrate Stencil into a Swift project:

Projects that use Stencil

Sourcery, SwiftGen, Kitura, Weaver, Genesis

License

Stencil is licensed under the BSD license. See LICENSE for more info.

Description
A simple and powerful template language for Swift.
Readme 993 KiB
Languages
Swift 74.6%
HTML 16.6%
Ruby 8.5%
Shell 0.3%