Remove HB prefix, make Parser private (#26)
This commit is contained in:
@@ -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
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user