Fix bunch of warnings

This commit is contained in:
David Jennes
2022-07-27 02:11:09 +02:00
parent d9a48fbda6
commit 0bbb8005bb
7 changed files with 14 additions and 15 deletions

View File

@@ -179,7 +179,7 @@ _None_
- The `{% for %}` tag can now iterate over tuples, structures and classes via - The `{% for %}` tag can now iterate over tuples, structures and classes via
their stored properties. their stored properties.
[Ilya Puchka](https://github.com/ilyapuchka) [Ilya Puchka](https://github.com/ilyapuchka)
[#172](https://github.com/stencilproject/Stencil/pull/173) [#173](https://github.com/stencilproject/Stencil/pull/173)
- Added `split` filter. - Added `split` filter.
[Ilya Puchka](https://github.com/ilyapuchka) [Ilya Puchka](https://github.com/ilyapuchka)
[#187](https://github.com/stencilproject/Stencil/pull/187) [#187](https://github.com/stencilproject/Stencil/pull/187)
@@ -288,7 +288,7 @@ _None_
### Bug Fixes ### Bug Fixes
- You can now use literal filter arguments which contain quotes. - You can now use literal filter arguments which contain quotes.
[#98](https://github.com/kylef/Stencil/pull/98) [#98](https://github.com/stencilproject/Stencil/pull/98)
## 0.8.0 ## 0.8.0
@@ -432,10 +432,10 @@ _None_
- Variables (`{{ variable.5 }}`) that reference an array index at an unknown - Variables (`{{ variable.5 }}`) that reference an array index at an unknown
index will now resolve to `nil` instead of causing a crash. index will now resolve to `nil` instead of causing a crash.
[#72](https://github.com/kylef/Stencil/issues/72) [#72](https://github.com/stencilproject/Stencil/issues/72)
- Templates can now extend templates that extend other templates. - Templates can now extend templates that extend other templates.
[#60](https://github.com/kylef/Stencil/issues/60) [#60](https://github.com/stencilproject/Stencil/issues/60)
- If comparisons will now treat 0 and below numbers as negative. - If comparisons will now treat 0 and below numbers as negative.

View File

@@ -36,7 +36,7 @@ open class Extension {
/// Registers a template filter with the given name /// Registers a template filter with the given name
public func registerFilter(_ name: String, filter: @escaping (Any?, [Any?]) throws -> Any?) { public func registerFilter(_ name: String, filter: @escaping (Any?, [Any?]) throws -> Any?) {
filters[name] = .arguments({ value, args, _ in try filter(value, args) }) filters[name] = .arguments { value, args, _ in try filter(value, args) }
} }
/// Registers a template filter with the given name /// Registers a template filter with the given name

View File

@@ -35,10 +35,8 @@ class BlockContext {
extension Collection { extension Collection {
func any(_ closure: (Iterator.Element) -> Bool) -> Iterator.Element? { func any(_ closure: (Iterator.Element) -> Bool) -> Iterator.Element? {
for element in self { for element in self where closure(element) {
if closure(element) { return element
return element
}
} }
return nil return nil

View File

@@ -1,5 +1,5 @@
public func until(_ tags: [String]) -> ((TokenParser, Token) -> Bool) { public func until(_ tags: [String]) -> ((TokenParser, Token) -> Bool) {
return { parser, token in return { _, token in
if let name = token.components.first { if let name = token.components.first {
for tag in tags where name == tag { for tag in tags where name == tag {
return true return true

View File

@@ -48,7 +48,8 @@ public struct Variable: Equatable, Resolvable {
/// Resolve the variable in the given context /// Resolve the variable in the given context
public func resolve(_ context: Context) throws -> Any? { public func resolve(_ context: Context) throws -> Any? {
if variable.count > 1 && ((variable.hasPrefix("'") && variable.hasSuffix("'")) || (variable.hasPrefix("\"") && variable.hasSuffix("\""))) { if variable.count > 1 &&
((variable.hasPrefix("'") && variable.hasSuffix("'")) || (variable.hasPrefix("\"") && variable.hasSuffix("\""))) {
// String literal // String literal
return String(variable[variable.index(after: variable.startIndex) ..< variable.index(before: variable.endIndex)]) return String(variable[variable.index(after: variable.startIndex) ..< variable.index(before: variable.endIndex)])
} }

View File

@@ -117,7 +117,7 @@ final class LexerTests: XCTestCase {
} }
func testPerformance() throws { func testPerformance() throws {
let path = Path(#file as String) + ".." + "fixtures" + "huge.html" let path = Path(#file as String) + ".." + "fixtures" + "huge.html"
let content: String = try path.read() let content: String = try path.read()
measure { measure {