Remove HB prefix, make Parser private (#26)

This commit is contained in:
Adam Fowler
2024-03-11 22:07:05 +00:00
committed by GitHub
parent f029081b61
commit bdfa05391a
25 changed files with 300 additions and 262 deletions

View File

@@ -2,17 +2,17 @@
The library doesn't provide a lambda implementation but it does provide something akin to the lambda feature.
Add a `HBMustacheLambda` to the object you want to be rendered and it can be used in a similar way to lambdas are used in Mustache. When you create a section referencing the lambda the contents of the section are passed as a template along with the current object to the lamdba function. This is slightly different from the standard implementation where the unprocessed text is passed to the lambda.
Add a `MustacheLambda` to the object you want to be rendered and it can be used in a similar way to lambdas are used in Mustache. When you create a section referencing the lambda the contents of the section are passed as a template along with the current object to the lamdba function. This is slightly different from the standard implementation where the unprocessed text is passed to the lambda.
Given the object `person` defined below
```swift
struct Person {
let name: String
let wrapped: HBMustacheLambda
let wrapped: MustacheLambda
}
let person = Person(
name: "John",
wrapped: HBMustacheLambda { object, template in
wrapped: MustacheLambda { object, template in
return "<b>\(template.render(object))</b>"
}
)
@@ -21,7 +21,7 @@ let person = Person(
and the following mustache template
```swift
let mustache = "{{#wrapped}}{{name}} is awesome.{{/wrapped}}"
let template = try HBMustacheTemplate(string: mustache)
let template = try MustacheTemplate(string: mustache)
```
Then `template.render(person)` will output
```