Class
LeafRenderer
LeafRenderer implements the full Leaf language pipeline.final class LeafRenderer
Overview
It must be configured before use with the appropriate LeafConfiguration and consituent threadsafe protocol-implementating modules (an NIO EventLoop, LeafCache, LeafSource, and potentially any number of custom LeafTag additions to the language).
Additional instances of LeafRenderer can then be created using these shared modules to allow concurrent rendering, potentially with unique per-instance scoped data via userInfo.
Topics
Initializers
init(configuration: LeafConfiguration, tags: [String : any LeafTag], cache: any LeafCache, sources: LeafSources, eventLoop: any EventLoop, userInfo: [AnyHashable : Any])Initial configuration of LeafRenderer.
Instance Properties
let cache: any LeafCacheA thread-safe implementation ofLeafCacheprotocollet configuration: LeafConfigurationAn initializedLeafConfigurationspecificying default directory and tagIndicatorlet eventLoop: any EventLoopThe NIOEventLoopon which this instance ofLeafRendererwill operatelet sources: LeafSourcesA thread-safe implementation ofLeafSourceprotocollet tags: [String : any LeafTag]A keyed dictionary of customLeafTagsto extend Leaf’s basic functionality, registered with the names which will call them when rendering - egtags["tagName"]can be used in a template as#tagName(parameters)let userInfo: [AnyHashable : Any]Any custom instance data to use (eg, in Vapor, theApplicationand/orRequestdata)
Instance Methods
func render(path: String, context: [String : LeafData]) -> EventLoopFuture<ByteBuffer>The public interface toLeafRenderer