Files
swiftpm-mustache/Sources/HummingbirdMustache/Library.swift
2021-03-12 08:41:13 +00:00

18 lines
475 B
Swift

public class HBMustacheLibrary {
init() {
self.templates = [:]
}
public func register(_ template: HBMustacheTemplate, named name: String) {
templates[name] = template
}
public func render(_ object: Any, withTemplateNamed name: String) -> String? {
guard let template = templates[name] else { return nil }
return template.render(object, library: self)
}
var templates: [String: HBMustacheTemplate]
}