I'm struggling to add a custom transform for a string value. Is this supported by the library?
import Mustache
public extension StringProtocol {
func transform(_ name: String) -> Any? {
switch name {
case "appendWithCake":
self + "cake"
default:
nil
}
}
}
extension String: MustacheTransformable {}
extension Substring: MustacheTransformable {}
let template = try MustacheTemplate(string: """
{{ appendWithCake(value) }}
""")
let object: [String: Any] = ["value": "Cup"]
XCTAssertEqual(template.render(object), "Cupcake") // Actual: ""
I'm struggling to add a custom transform for a string value. Is this supported by the library?