Fix issue with indented partials (#19)
* Fix issue with indented partials * Add test * Add empty transform for string
This commit is contained in:
@@ -27,14 +27,16 @@ extension HBMustacheTemplate {
|
||||
|
||||
if let indentation = context.indentation, indentation != "" {
|
||||
for token in tokens {
|
||||
if string.last == "\n" {
|
||||
let renderedString = self.renderToken(token, context: &context)
|
||||
if renderedString != "", string.last == "\n" {
|
||||
string += indentation
|
||||
}
|
||||
string += self.renderToken(token, context: &context)
|
||||
string += renderedString
|
||||
}
|
||||
} else {
|
||||
for token in tokens {
|
||||
string += self.renderToken(token, context: &context)
|
||||
let result = self.renderToken(token, context: &context)
|
||||
string += result
|
||||
}
|
||||
}
|
||||
return string
|
||||
|
||||
@@ -39,6 +39,8 @@ public extension StringProtocol {
|
||||
/// - Returns: Result
|
||||
func transform(_ name: String) -> Any? {
|
||||
switch name {
|
||||
case "empty":
|
||||
return isEmpty
|
||||
case "capitalized":
|
||||
return capitalized
|
||||
case "lowercased":
|
||||
|
||||
Reference in New Issue
Block a user