swift format
This commit is contained in:
@@ -404,6 +404,7 @@ extension HBParser {
|
||||
func getPosition() -> Int {
|
||||
return index
|
||||
}
|
||||
|
||||
mutating func setPosition(_ index: Int) throws {
|
||||
guard range.contains(index) else { throw Error.invalidPosition }
|
||||
guard validateUTF8Character(at: index).0 != nil else { throw Error.invalidPosition }
|
||||
|
||||
@@ -61,7 +61,7 @@ extension HBMustacheTemplate {
|
||||
// section
|
||||
parser.unsafeAdvance()
|
||||
let (name, method) = try parseName(&parser)
|
||||
if newLine && hasLineFinished(&parser) {
|
||||
if newLine, hasLineFinished(&parser) {
|
||||
setNewLine = true
|
||||
if parser.current() == "\n" {
|
||||
parser.unsafeAdvance()
|
||||
@@ -77,7 +77,7 @@ extension HBMustacheTemplate {
|
||||
// inverted section
|
||||
parser.unsafeAdvance()
|
||||
let (name, method) = try parseName(&parser)
|
||||
if newLine && hasLineFinished(&parser) {
|
||||
if newLine, hasLineFinished(&parser) {
|
||||
setNewLine = true
|
||||
if parser.current() == "\n" {
|
||||
parser.unsafeAdvance()
|
||||
@@ -96,7 +96,7 @@ extension HBMustacheTemplate {
|
||||
guard name == sectionName else {
|
||||
throw Error.sectionCloseNameIncorrect
|
||||
}
|
||||
if newLine && hasLineFinished(&parser) {
|
||||
if newLine, hasLineFinished(&parser) {
|
||||
setNewLine = true
|
||||
if parser.current() == "\n" {
|
||||
parser.unsafeAdvance()
|
||||
@@ -111,7 +111,7 @@ extension HBMustacheTemplate {
|
||||
// comment
|
||||
parser.unsafeAdvance()
|
||||
_ = try parseComment(&parser)
|
||||
if newLine && hasLineFinished(&parser) {
|
||||
if newLine, hasLineFinished(&parser) {
|
||||
setNewLine = true
|
||||
if !parser.reachedEnd() {
|
||||
parser.unsafeAdvance()
|
||||
@@ -152,7 +152,7 @@ extension HBMustacheTemplate {
|
||||
if whiteSpaceBefore.count > 0 {
|
||||
tokens.append(.text(whiteSpaceBefore))
|
||||
}
|
||||
if newLine && hasLineFinished(&parser) {
|
||||
if newLine, hasLineFinished(&parser) {
|
||||
setNewLine = true
|
||||
if parser.current() == "\n" {
|
||||
parser.unsafeAdvance()
|
||||
|
||||
@@ -13,7 +13,6 @@ func test(_ object: Any, _ template: String, _ expected: String) throws {
|
||||
// MARK: Comments
|
||||
|
||||
final class SpecCommentsTests: XCTestCase {
|
||||
|
||||
func testInline() throws {
|
||||
let object = {}
|
||||
let template = "12345{{! Comment Block! }}67890"
|
||||
@@ -121,7 +120,6 @@ final class SpecInterpolationTests: XCTestCase {
|
||||
let template = "Hello from {Mustache}!"
|
||||
let expected = "Hello from {Mustache}!"
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testBasicInterpolation() throws {
|
||||
@@ -129,7 +127,6 @@ final class SpecInterpolationTests: XCTestCase {
|
||||
let template = "Hello, {{subject}}!"
|
||||
let expected = "Hello, world!"
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testHTMLEscaping() throws {
|
||||
@@ -137,7 +134,6 @@ final class SpecInterpolationTests: XCTestCase {
|
||||
let template = "These characters should be HTML escaped: {{forbidden}}"
|
||||
let expected = #"These characters should be HTML escaped: & " < >"#
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testTripleMustache() throws {
|
||||
@@ -145,7 +141,6 @@ final class SpecInterpolationTests: XCTestCase {
|
||||
let template = "These characters should not be HTML escaped: {{{forbidden}}}"
|
||||
let expected = #"These characters should not be HTML escaped: & " < >"#
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testAmpersand() throws {
|
||||
@@ -153,7 +148,6 @@ final class SpecInterpolationTests: XCTestCase {
|
||||
let template = "These characters should not be HTML escaped: {{&forbidden}}"
|
||||
let expected = #"These characters should not be HTML escaped: & " < >"#
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testBasicInteger() throws {
|
||||
@@ -250,7 +244,7 @@ final class SpecInterpolationTests: XCTestCase {
|
||||
func testInitialResolutionDottedName() throws {
|
||||
let object = [
|
||||
"a": ["b": ["c": ["d": ["e": ["name": "Phil"]]]]],
|
||||
"b": ["c": ["d": ["e": ["name": "Wrong"]]]]
|
||||
"b": ["c": ["d": ["e": ["name": "Wrong"]]]],
|
||||
]
|
||||
let template = #""{{#a}}{{b.c.d.e.name}}{{/a}}" == "Phil""#
|
||||
let expected = #""Phil" == "Phil""#
|
||||
@@ -260,7 +254,7 @@ final class SpecInterpolationTests: XCTestCase {
|
||||
func testContextPrecedenceDottedName() throws {
|
||||
let object = [
|
||||
"a": ["b": []],
|
||||
"b": ["c": "Error"]
|
||||
"b": ["c": "Error"],
|
||||
]
|
||||
let template = #"{{#a}}{{b.c}}{{/a}}"#
|
||||
let expected = ""
|
||||
@@ -314,7 +308,6 @@ final class SpecInterpolationTests: XCTestCase {
|
||||
let template = "|{{ string }}|"
|
||||
let expected = "|---|"
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testTripleMustacheWithPadding() throws {
|
||||
@@ -322,7 +315,6 @@ final class SpecInterpolationTests: XCTestCase {
|
||||
let template = "|{{{ string }}}|"
|
||||
let expected = "|---|"
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testAmpersandWithPadding() throws {
|
||||
@@ -341,7 +333,6 @@ final class SpecInvertedTests: XCTestCase {
|
||||
let template = #""{{^boolean}}This should be rendered.{{/boolean}}""#
|
||||
let expected = #""This should be rendered.""#
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testTrue() throws {
|
||||
@@ -349,7 +340,6 @@ final class SpecInvertedTests: XCTestCase {
|
||||
let template = #""{{^boolean}}This should not be rendered.{{/boolean}}""#
|
||||
let expected = "\"\""
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testContext() throws {
|
||||
@@ -357,7 +347,6 @@ final class SpecInvertedTests: XCTestCase {
|
||||
let template = #""{{^context}}Hi {{name}}.{{/context}}""#
|
||||
let expected = "\"\""
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testList() throws {
|
||||
@@ -365,7 +354,6 @@ final class SpecInvertedTests: XCTestCase {
|
||||
let template = #""{{^list}}{{n}}{{/list}}""#
|
||||
let expected = "\"\""
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testEmptyList() throws {
|
||||
@@ -442,7 +430,6 @@ final class SpecInvertedTests: XCTestCase {
|
||||
let template = " | {{^boolean}}\t|\t{{/boolean}} | \n"
|
||||
let expected = " | \t|\t | \n"
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testInternalWhitespace() throws {
|
||||
@@ -450,7 +437,6 @@ final class SpecInvertedTests: XCTestCase {
|
||||
let template = " | {{^boolean}} {{! Important Whitespace }}\n {{/boolean}} | \n"
|
||||
let expected = " | \n | \n"
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testIndentedInline() throws {
|
||||
@@ -458,7 +444,6 @@ final class SpecInvertedTests: XCTestCase {
|
||||
let template = " {{^boolean}}NO{{/boolean}}\n {{^boolean}}WAY{{/boolean}}\n"
|
||||
let expected = " NO\n WAY\n"
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testStandaloneLines() throws {
|
||||
@@ -476,7 +461,6 @@ final class SpecInvertedTests: XCTestCase {
|
||||
| A Line
|
||||
"""
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testStandaloneIndentedLines() throws {
|
||||
@@ -501,7 +485,6 @@ final class SpecInvertedTests: XCTestCase {
|
||||
let template = "|\r\n{{^boolean}}\r\n{{/boolean}}\r\n|"
|
||||
let expected = "|\r\n|"
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testStandaloneWithoutPreviousLine() throws {
|
||||
@@ -653,7 +636,6 @@ final class SpecSectionTests: XCTestCase {
|
||||
let template = #""{{#boolean}}This should be rendered.{{/boolean}}""#
|
||||
let expected = #""This should be rendered.""#
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testFalse() throws {
|
||||
@@ -661,7 +643,6 @@ final class SpecSectionTests: XCTestCase {
|
||||
let template = #""{{#boolean}}This should not be rendered.{{/boolean}}""#
|
||||
let expected = "\"\""
|
||||
try test(object, template, expected)
|
||||
|
||||
}
|
||||
|
||||
func testContext() throws {
|
||||
@@ -819,7 +800,6 @@ final class SpecSectionTests: XCTestCase {
|
||||
try test(object, template, expected)
|
||||
}
|
||||
|
||||
|
||||
func testDottedNameTrue() throws {
|
||||
let object = ["a": ["b": ["c": true]]]
|
||||
let template = #""{{#a.b.c}}Here{{/a.b.c}}" == "Here""#
|
||||
|
||||
Reference in New Issue
Block a user