refactor: Use tabs for indent

This commit is contained in:
T. R. Bernstein
2025-09-30 19:02:50 +02:00
parent 6811c71bd6
commit 25d1507159
44 changed files with 5423 additions and 5423 deletions

View File

@@ -3,68 +3,68 @@ import Stencil
import XCTest
final class StencilTests: XCTestCase {
private lazy var environment: Environment = {
let exampleExtension = Extension()
exampleExtension.registerSimpleTag("simpletag") { _ in
"Hello World"
}
exampleExtension.registerTag("customtag") { _, token in
CustomNode(token: token)
}
return Environment(extensions: [exampleExtension])
}()
private lazy var environment: Environment = {
let exampleExtension = Extension()
exampleExtension.registerSimpleTag("simpletag") { _ in
"Hello World"
}
exampleExtension.registerTag("customtag") { _, token in
CustomNode(token: token)
}
return Environment(extensions: [exampleExtension])
}()
func testStencil() {
it("can render the README example") {
let templateString = """
There are {{ articles.count }} articles.
func testStencil() {
it("can render the README example") {
let templateString = """
There are {{ articles.count }} articles.
{% for article in articles %}\
- {{ article.title }} by {{ article.author }}.
{% endfor %}
"""
{% for article in articles %}\
- {{ article.title }} by {{ article.author }}.
{% endfor %}
"""
let context = [
"articles": [
Article(title: "Migrating from OCUnit to XCTest", author: "Kyle Fuller"),
Article(title: "Memory Management with ARC", author: "Kyle Fuller")
]
]
let context = [
"articles": [
Article(title: "Migrating from OCUnit to XCTest", author: "Kyle Fuller"),
Article(title: "Memory Management with ARC", author: "Kyle Fuller")
]
]
let template = Template(templateString: templateString)
let result = try template.render(context)
let template = Template(templateString: templateString)
let result = try template.render(context)
try expect(result) == """
There are 2 articles.
try expect(result) == """
There are 2 articles.
- Migrating from OCUnit to XCTest by Kyle Fuller.
- Memory Management with ARC by Kyle Fuller.
- Migrating from OCUnit to XCTest by Kyle Fuller.
- Memory Management with ARC by Kyle Fuller.
"""
}
"""
}
it("can render a custom template tag") {
let result = try self.environment.renderTemplate(string: "{% customtag %}")
try expect(result) == "Hello World"
}
it("can render a custom template tag") {
let result = try self.environment.renderTemplate(string: "{% customtag %}")
try expect(result) == "Hello World"
}
it("can render a simple custom tag") {
let result = try self.environment.renderTemplate(string: "{% simpletag %}")
try expect(result) == "Hello World"
}
}
it("can render a simple custom tag") {
let result = try self.environment.renderTemplate(string: "{% simpletag %}")
try expect(result) == "Hello World"
}
}
}
// MARK: - Helpers
private struct CustomNode: NodeType {
let token: Token?
func render(_ context: Context) throws -> String {
"Hello World"
}
let token: Token?
func render(_ context: Context) throws -> String {
"Hello World"
}
}
private struct Article {
let title: String
let author: String
let title: String
let author: String
}