Instance Method
render(_:_:)
Renders a view by returning the contents of the file.
func render<E>(_ name: String, _ context: E) async throws -> View where E : Encodable
Parameters
nameThe name of the view to render, either an absolute path or a path relative to the views directory.
contextThe rendering context. Ignored by this renderer.
Return Value
A View containing the raw file contents.
Discussion
If name is an absolute path (begins with /), it is used as-is; otherwise it is resolved against the renderer’s views directory. The context is ignored, as no templating is applied.
Warning
The name of the template is not sanitized, so you should ensure that you trust any input passed to it, or sanitize it to prevent directory traversal attacks
Throws
An error if the file cannot be read, or if its size exceeds 32 megabytes.