swift format

This commit is contained in:
Adam Fowler
2021-03-15 18:24:06 +00:00
parent 955e1eb9e4
commit 66edcba185
18 changed files with 306 additions and 313 deletions

View File

@@ -7,12 +7,12 @@ public protocol HBMustacheSequence {
func renderInvertedSection(with template: HBMustacheTemplate) -> String
}
extension Sequence {
public extension Sequence {
/// Render section using template
public func renderSection(with template: HBMustacheTemplate) -> String {
func renderSection(with template: HBMustacheTemplate) -> String {
var string = ""
var context = HBMustacheContext(first: true)
var iterator = self.makeIterator()
var iterator = makeIterator()
guard var currentObject = iterator.next() else { return "" }
while let object = iterator.next() {
@@ -24,19 +24,18 @@ extension Sequence {
context.last = true
string += template.render(currentObject, context: context)
return string
}
/// Render inverted section using template
public func renderInvertedSection(with template: HBMustacheTemplate) -> String {
func renderInvertedSection(with template: HBMustacheTemplate) -> String {
var iterator = makeIterator()
if iterator.next() == nil {
return template.render(self)
}
return ""
}
}
extension Array: HBMustacheSequence {}