Skip to content

Commit

Permalink
Fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AliSoftware committed May 27, 2017
1 parent 848cd32 commit d3d53bc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
12 changes: 6 additions & 6 deletions Sources/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public extension Extension {
registerTag("call", parser: CallNode.parse)
registerTag("map", parser: MapNode.parse)

registerFilter("camelToSnakeCase", filter: Filters.Strings.camelToSnakeCase)
registerFilter("escapeReservedKeywords", filter: Filters.Strings.escapeReservedKeywords)
registerFilter("lowerFirstWord", filter: Filters.Strings.lowerFirstWord)
registerFilter("removeNewlines", filter: Filters.Strings.removeNewlines)
registerFilter("snakeToCamelCase", filter: Filters.Strings.snakeToCamelCase)
registerFilter("swiftIdentifier", filter: Filters.Strings.stringToSwiftIdentifier)
registerFilter("camelToSnakeCase", filter: Filters.Strings.camelToSnakeCase)
registerFilter("escapeReservedKeywords", filter: Filters.Strings.escapeReservedKeywords)
registerFilter("lowerFirstWord", filter: Filters.Strings.lowerFirstWord)
registerFilter("removeNewlines", filter: Filters.Strings.removeNewlines)
registerFilter("snakeToCamelCase", filter: Filters.Strings.snakeToCamelCase)
registerFilter("swiftIdentifier", filter: Filters.Strings.stringToSwiftIdentifier)
registerFilter("titlecase", filter: Filters.Strings.titlecase)

registerFilter("hexToInt", filter: Filters.Numbers.hexToInt)
Expand Down
14 changes: 7 additions & 7 deletions Sources/Filters+Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ extension Filters {
return escapeReservedKeywords(in: string)
}

static func removeNewlines(_ value: Any?, arguments: [Any?]) throws -> Any? {
let removeSpaces = try Filters.parseBool(from: arguments, index: 0, required: false) ?? true
guard let string = value as? String else { throw Filters.Error.invalidInputType }
static func removeNewlines(_ value: Any?, arguments: [Any?]) throws -> Any? {
let removeSpaces = try Filters.parseBool(from: arguments, index: 0, required: false) ?? true
guard let string = value as? String else { throw Filters.Error.invalidInputType }

let set: CharacterSet = removeSpaces ? .whitespacesAndNewlines : .newlines
let result = string.components(separatedBy: set).joined()
let set: CharacterSet = removeSpaces ? .whitespacesAndNewlines : .newlines
let result = string.components(separatedBy: set).joined()

return result
}
return result
}

// MARK: - Private methods

Expand Down
34 changes: 17 additions & 17 deletions Sources/MapNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MapNode: NodeType {

if let values = values as? [Any], values.count > 0 {
let mappedValues: [String] = try values.enumerated().map { (index, item) in
let mapContext = self.context(values: values, index: index, item: item)
let mapContext = self.context(values: values, index: index, item: item)

return try context.push(dictionary: mapContext) {
try renderNodes(nodes, context)
Expand All @@ -68,20 +68,20 @@ class MapNode: NodeType {
return ""
}

func context(values: [Any], index: Int, item: Any) -> [String: Any] {
var result: [String: Any] = [
"maploop": [
"counter": index,
"first": index == 0,
"last": index == (values.count - 1),
"item": item
]
]

if let mapVariable = mapVariable {
result[mapVariable] = item
}

return result
}
func context(values: [Any], index: Int, item: Any) -> [String: Any] {
var result: [String: Any] = [
"maploop": [
"counter": index,
"first": index == 0,
"last": index == (values.count - 1),
"item": item
]
]

if let mapVariable = mapVariable {
result[mapVariable] = item
}

return result
}
}

0 comments on commit d3d53bc

Please sign in to comment.