Compare commits

..

10 Commits

Author SHA1 Message Date
T. R. Bernstein
040862a0c0 Adapt project for Astzweig
Some checks failed
CI / macOS (push) Has been cancelled
CI / linux (swift:6.0) (push) Has been cancelled
CI / linux (swift:6.1) (push) Has been cancelled
CI / linux (swift:6.2) (push) Has been cancelled
CI / windows (6.1) (push) Has been cancelled
2025-09-29 14:28:48 +02:00
hummingbird-automation[bot]
999fda1e52 Update from hummingbird-project-template 144a72a2fd91b62f02696dabc6ed1819205d4dcd (#73)
Co-authored-by: adam-fowler <adam-fowler@users.noreply.github.com>
2025-09-17 10:06:29 +01:00
Adam Fowler
534f9f9e60 Add testPartialInSubfolder (#72)
* Add testPartialInSubfolder

* Replace windows folder separator with mac/linux folder separator
2025-09-01 09:59:05 +01:00
Ralph Kühnert
6df64896f4 Add / as a valid partialNameChar and use it in parse (#71)
* Add / as a valid partialNameChar and use it in parse

* maybe let's not keep "bla" in the tests
2025-08-30 16:13:26 +01:00
dependabot[bot]
28df3156e2 Bump actions/checkout from 4 to 5 in the dependencies group (#70) 2025-08-12 14:06:41 +02:00
hummingbird-automation[bot]
2aee7d23bc Update from hummingbird-project-template 9f1753de24c31bae77d963d51cc52bff1d895b4e (#68)
Co-authored-by: Joannis <Joannis@users.noreply.github.com>
2025-06-23 12:27:54 +01:00
hummingbird-automation[bot]
aaacbd989b Update from hummingbird-project-template e9eae39c0a5fff1b127f751ff4e166635a2e34ee (#67)
Co-authored-by: adam-fowler <adam-fowler@users.noreply.github.com>
2025-04-05 16:37:56 +01:00
Go Takagi
2add8847a1 Support Swift 6 mode (#65)
* Enable swift 6 mode

* Attach Sendable

* Stop async context because enumerator can use only synchronous contexts

* Fix global shared mutable state for MustacheContentTypes

* Revert "Fix global shared mutable state for MustacheContentTypes"

This reverts commit d4ccc83e07aeb48f4aa4024b71eb8e5f70131bc5.

* Use  instead of lock

* Support 5 and 6 versions

* Lock on access in Swift 6

* Support 5.9

* Revert "Support 5.9"

This reverts commit 9845b3bc448b2af7238c3ac88aabe6d764b2e667.

* Fix 5.9 compatibility

* Unify to manage the same lock logic in 5.9 and 6

* Add withLock backport in NSLock
2025-03-26 09:53:44 +00:00
hummingbird-automation[bot]
eeb4eec97f Update from hummingbird-project-template 39b2227dee2e6590b8dc0b72820f09433a569c17 (#62) 2025-01-30 07:41:59 +00:00
hummingbird-automation[bot]
c8b6af450d Update from hummingbird-project-template 812da0c4a36c77ed781dd120d6d6dee7ca7841c2 (#61)
Co-authored-by: adam-fowler <adam-fowler@users.noreply.github.com>
2025-01-29 11:13:29 +00:00
37 changed files with 92 additions and 495 deletions

2
.github/CODEOWNERS vendored
View File

@@ -1 +1 @@
* @adam-fowler @Joannis
* @astzweig/coders

1
.github/FUNDING.yml vendored
View File

@@ -1 +0,0 @@
github: adam-fowler

View File

@@ -4,6 +4,9 @@ updates:
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "codecov/codecov-action"
update-types: ["version-update:semver-major"]
groups:
dependencies:
patterns:

View File

@@ -14,7 +14,7 @@ jobs:
image: swift:latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 0
# https://github.com/actions/checkout/issues/766

View File

@@ -19,7 +19,7 @@ jobs:
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: SPM tests
run: swift test --enable-code-coverage
- name: Convert coverage files
@@ -30,20 +30,21 @@ jobs:
-ignore-filename-regex="\/Benchmarks\/" \
-instr-profile=.build/debug/codecov/default.profdata > info.lcov
- name: Upload to codecov.io
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v4
with:
files: info.lcov
token: ${{ secrets.CODECOV_TOKEN }}
linux:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
image: ["swift:5.9", "swift:5.10", "swift:6.0", "swiftlang/swift:nightly-6.1-jammy"]
image: ["swift:6.0", "swift:6.1", "swift:6.2"]
container:
image: ${{ matrix.image }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Test
run: |
swift test --enable-code-coverage
@@ -55,18 +56,19 @@ jobs:
-ignore-filename-regex="\/Benchmarks\/" \
-instr-profile .build/debug/codecov/default.profdata > info.lcov
- name: Upload to codecov.io
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v4
with:
files: info.lcov
token: ${{ secrets.CODECOV_TOKEN }}
windows:
runs-on: windows-latest
strategy:
matrix:
swift-version: ["6.0"]
swift-version: ["6.1"]
steps:
- uses: compnerd/gha-setup-swift@main
with:
branch: swift-${{ matrix.swift-version }}-release
tag: ${{ matrix.swift-version }}-RELEASE
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- run: swift test

View File

@@ -14,7 +14,7 @@ jobs:
image: swiftlang/swift:${{ matrix.image }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Test
run: |
swift test

View File

@@ -12,7 +12,7 @@ jobs:
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 1
- name: run script

View File

@@ -17,12 +17,12 @@ jobs:
run: |
apt-get update && apt-get install -y rsync bc
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 0
path: "package"
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
repository: "hummingbird-project/hummingbird-docs"
fetch-depth: 0

View File

@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
@@ -13,5 +13,6 @@ let package = Package(
targets: [
.target(name: "Mustache", dependencies: []),
.testTarget(name: "MustacheTests", dependencies: ["Mustache"]),
]
],
swiftLanguageVersions: [.v5, .version("6")]
)

View File

@@ -2,6 +2,9 @@
Package for rendering Mustache templates. Mustache is a "logic-less" templating language commonly used in web and mobile platforms. You can find out more about Mustache [here](http://mustache.github.io/mustache.5.html).
> [!NOTE]
> This repository is a fork of [hummingbird-project/swift-mustache](https://github.com/hummingbird-project/swift-mustache). It may contain modifications required by our other open source tools.
## Usage
Load your templates from the filesystem

View File

@@ -1,16 +1,4 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
/// Protocol for content types
public protocol MustacheContentType: Sendable {
@@ -38,8 +26,13 @@ struct HTMLContentType: MustacheContentType {
/// the content type required. The default available types are `TEXT` and `HTML`. You can register your own
/// with `MustacheContentTypes.register`.
public enum MustacheContentTypes {
private static let lock = NSLock()
static func get(_ name: String) -> MustacheContentType? {
self.types[name]
lock.withLock {
self.types[name]
}
}
/// Register new content type
@@ -47,11 +40,19 @@ public enum MustacheContentTypes {
/// - contentType: Content type
/// - name: String to identify it
public static func register(_ contentType: MustacheContentType, named name: String) {
self.types[name] = contentType
lock.withLock {
self.types[name] = contentType
}
}
static var types: [String: MustacheContentType] = [
private static let _types: [String: MustacheContentType] = [
"HTML": HTMLContentType(),
"TEXT": TextContentType(),
]
#if compiler(>=6.0)
nonisolated(unsafe) static var types: [String: MustacheContentType] = _types
#else
static var types: [String: MustacheContentType] = _types
#endif
}

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2024 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// Context while rendering mustache tokens
struct MustacheContext {
let stack: [Any]

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
/// Allow object to override standard hummingbird type rendering which uses

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2024 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
// Below is a list of unavailable symbols with the "HB" prefix. These are available
// temporarily to ease transition from the old symbols that included the "HB"
// prefix to the new ones.

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// Lambda function. Can add this to object being rendered to filter contents of objects.
///
/// See http://mustache.github.io/mustache.5.html for more details on

View File

@@ -1,22 +1,8 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2024 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
extension MustacheLibrary {
/// Load templates from a folder
static func loadTemplates(from directory: String, withExtension extension: String = "mustache") async throws -> [String: MustacheTemplate] {
static func loadTemplates(from directory: String, withExtension extension: String = "mustache") throws -> [String: MustacheTemplate] {
var directory = directory
if !directory.hasSuffix("/") {
directory += "/"
@@ -31,7 +17,11 @@ extension MustacheLibrary {
guard let template = try MustacheTemplate(filename: directory + path) else { continue }
// drop ".mustache" from path to get name
let name = String(path.dropLast(extWithDot.count))
#if os(Windows)
templates[name.replacingOccurrences(of: "\\", with: "/")] = template
#else
templates[name] = template
#endif
} catch let error as MustacheTemplate.ParserError {
throw ParserError(filename: path, context: error.context, error: error.error)
}

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2024 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// Class holding a collection of mustache templates.
///
/// Each template can reference the others via a partial using the name the template is registered under
@@ -39,7 +25,7 @@ public struct MustacheLibrary: Sendable {
/// - Parameter directory: Directory to look for mustache templates
/// - Parameter extension: Extension of files to look for
public init(directory: String, withExtension extension: String = "mustache") async throws {
self.templates = try await Self.loadTemplates(from: directory, withExtension: `extension`)
self.templates = try Self.loadTemplates(from: directory, withExtension: `extension`)
}
/// Register template under name

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
extension Mirror {
/// Return value from Mirror given name
func getValue(forKey key: String) -> Any? {

View File

@@ -0,0 +1,13 @@
#if compiler(<6.0)
import Foundation
extension NSLock {
func withLock<Value>(_ operation: () throws -> Value) rethrows -> Value {
self.lock()
defer {
self.unlock()
}
return try operation()
}
}
#endif

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// Protocol for object that has a custom method for accessing their children, instead
/// of using Mirror
public protocol MustacheParent {

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
/// Reader object for parsing String buffers
@@ -303,7 +289,7 @@ extension Parser {
}
/// context used in parser error
public struct MustacheParserContext {
public struct MustacheParserContext: Sendable {
public let line: String
public let lineNumber: Int
public let columnNumber: Int

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// Protocol for objects that can be rendered as a sequence in Mustache
public protocol MustacheSequence: Sequence {}

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// Context that current object inside a sequence is being rendered in. Only relevant when rendering a sequence
struct MustacheSequenceContext: MustacheTransformable {
var first: Bool

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
extension String {
private static let htmlEscapedCharacters: [Character: String] = [
"<": "&lt;",

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2024 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
extension MustacheTemplate {

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
extension MustacheTemplate {
/// Error return by `MustacheTemplate.parse`. Includes information about where error occurred
public struct ParserError: Swift.Error {
@@ -441,7 +427,7 @@ extension MustacheTemplate {
/// parse partial name
static func parsePartialName(_ parser: inout Parser, state: ParserState) throws -> String {
parser.read(while: \.isWhitespace)
let text = String(parser.read(while: self.sectionNameChars))
let text = String(parser.read(while: self.partialNameChars))
parser.read(while: \.isWhitespace)
guard try parser.read(string: state.endDelimiter) else { throw Error.unfinishedName }
return text
@@ -518,5 +504,5 @@ extension MustacheTemplate {
private static let sectionNameCharsWithoutBrackets = Set<Character>("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_?*")
private static let sectionNameChars = Set<Character>("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_?()*")
private static let partialNameChars = Set<Character>("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_()")
private static let partialNameChars = Set<Character>("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_?()*/")
}

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2024 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
extension MustacheTemplate {

View File

@@ -1,18 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2024 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// Class holding Mustache template
public struct MustacheTemplate: Sendable, CustomStringConvertible {
/// Initialize template
/// - Parameter string: Template text

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// Objects that can have a transforms run on them. Mustache transforms are specific to this implementation
/// of Mustache. They allow you to process objects before they are rendered.
///

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Mustache
import XCTest

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2024 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import XCTest
@testable import Mustache
@@ -48,6 +34,24 @@ final class LibraryTests: XCTestCase {
XCTAssertEqual(library.render(object, withTemplate: "test"), "<test><value>value1</value><value>value2</value></test>")
}
func testPartialInSubfolder() async throws {
let fs = FileManager()
try? fs.createDirectory(atPath: "templates/subfolder", withIntermediateDirectories: true)
let mustache = Data("<test>{{#value}}<value>{{.}}</value>{{/value}}</test>".utf8)
try mustache.write(to: URL(fileURLWithPath: "templates/subfolder/test-partial.mustache"))
let mustache2 = Data("{{>subfolder/test-partial}}".utf8)
try mustache2.write(to: URL(fileURLWithPath: "templates/test.mustache"))
defer {
XCTAssertNoThrow(try fs.removeItem(atPath: "templates/subfolder/test-partial.mustache"))
XCTAssertNoThrow(try fs.removeItem(atPath: "templates/test.mustache"))
XCTAssertNoThrow(try fs.removeItem(atPath: "templates"))
}
let library = try await MustacheLibrary(directory: "./templates")
let object = ["value": ["value1", "value2"]]
XCTAssertEqual(library.render(object, withTemplate: "test"), "<test><value>value1</value><value>value2</value></test>")
}
func testLibraryParserError() async throws {
let fs = FileManager()
try? fs.createDirectory(atPath: "templates", withIntermediateDirectories: false)

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import XCTest
@testable import Mustache
@@ -23,7 +9,7 @@ final class PartialTests: XCTestCase {
string: """
<h2>Names</h2>
{{#names}}
{{> user}}
{{> us/er}}
{{/names}}
"""
)
@@ -33,7 +19,7 @@ final class PartialTests: XCTestCase {
"""
)
let library = MustacheLibrary(templates: ["base": template, "user": template2])
let library = MustacheLibrary(templates: ["base": template, "us/er": template2])
let object: [String: Any] = ["names": ["john", "adam", "claire"]]
XCTAssertEqual(

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
import Mustache
import XCTest

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import XCTest
@testable import Mustache
@@ -65,11 +51,7 @@ extension MustacheTemplate {
}
}
#if hasFeature(RetroactiveAttribute)
extension MustacheTemplate: @retroactive Equatable {}
#else
extension MustacheTemplate: Equatable {}
#endif
extension MustacheTemplate.Token {
public static func == (lhs: MustacheTemplate.Token, rhs: MustacheTemplate.Token) -> Bool {
@@ -92,8 +74,4 @@ extension MustacheTemplate.Token {
}
}
#if hasFeature(RetroactiveAttribute)
extension MustacheTemplate.Token: @retroactive Equatable {}
#else
extension MustacheTemplate.Token: Equatable {}
#endif

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Mustache
import XCTest

View File

@@ -1,17 +1,3 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Mustache
import XCTest

View File

@@ -1,31 +1,4 @@
#!/bin/bash
##===----------------------------------------------------------------------===##
##
## This source file is part of the Hummingbird server framework project
##
## Copyright (c) 2021-2024 the Hummingbird authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
##
## SPDX-License-Identifier: Apache-2.0
##
##===----------------------------------------------------------------------===##
##===----------------------------------------------------------------------===##
##
## This source file is part of the SwiftNIO open source project
##
## Copyright (c) 2017-2019 Apple Inc. and the SwiftNIO project authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
##
## SPDX-License-Identifier: Apache-2.0
##
##===----------------------------------------------------------------------===##
SWIFT_FORMAT_VERSION=0.53.10
set -eu
@@ -49,78 +22,3 @@ if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
else
printf "\033[0;32mokay.\033[0m\n"
fi
printf "=> Checking license headers... "
tmp=$(mktemp /tmp/.soto-core-sanity_XXXXXX)
exit 0
for language in swift-or-c; do
declare -a matching_files
declare -a exceptions
expections=( )
matching_files=( -name '*' )
case "$language" in
swift-or-c)
exceptions=( -path '*/Benchmarks/.build/*' -o -name Package.swift)
matching_files=( -name '*.swift' -o -name '*.c' -o -name '*.h' )
cat > "$tmp" <<"EOF"
//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) YEARS the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
EOF
;;
bash)
matching_files=( -name '*.sh' )
cat > "$tmp" <<"EOF"
##===----------------------------------------------------------------------===##
##
## This source file is part of the Hummingbird server framework project
##
## Copyright (c) YEARS the Hummingbird authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
##
## SPDX-License-Identifier: Apache-2.0
##
##===----------------------------------------------------------------------===##
EOF
;;
*)
echo >&2 "ERROR: unknown language '$language'"
;;
esac
lines_to_compare=$(cat "$tmp" | wc -l | tr -d " ")
# need to read one more line as we remove the '#!' line
lines_to_read=$(expr "$lines_to_compare" + 1)
expected_sha=$(cat "$tmp" | shasum)
(
cd "$here/.."
find . \
\( \! -path './.build/*' -a \
\( "${matching_files[@]}" \) -a \
\( \! \( "${exceptions[@]}" \) \) \) | while read line; do
if [[ "$(cat "$line" | head -n $lines_to_read | replace_acceptable_years | head -n $lines_to_compare | shasum)" != "$expected_sha" ]]; then
printf "\033[0;31mmissing headers in file '$line'!\033[0m\n"
diff -u <(cat "$line" | head -n $lines_to_read | replace_acceptable_years | head -n $lines_to_compare) "$tmp"
exit 1
fi
done
printf "\033[0;32mokay.\033[0m\n"
)
done
rm "$tmp"