Add support for custom text escaping (#11)

* Add support for custom text escaping

* swift format

* Remove withDefaultDelimiters

* Update README.md

* Don't pass content type into partial
This commit is contained in:
Adam Fowler
2021-03-23 17:36:28 +00:00
committed by GitHub
parent ef4eb40eb7
commit d3edef1b8e
9 changed files with 164 additions and 16 deletions

View File

@@ -92,6 +92,13 @@ final class TemplateRendererTests: XCTestCase {
XCTAssertEqual(template.render(Test(test: .init(string: "sub"))), "test sub")
}
func testTextEscaping() throws {
let template1 = try HBMustacheTemplate(string: "{{% CONTENT_TYPE:TEXT}}{{.}}")
XCTAssertEqual(template1.render("<>"), "<>")
let template2 = try HBMustacheTemplate(string: "{{% CONTENT_TYPE:HTML}}{{.}}")
XCTAssertEqual(template2.render("<>"), "&lt;&gt;")
}
/// variables
func testMustacheManualExample1() throws {
let template = try HBMustacheTemplate(string: """