RenderDriver implementation for Mustache.
VaporMustache, add the following package to your
.Package(url: "https://github.com/qutheory/vapor-mustache.git", majorVersion: 0, minor: 8)
This package includes a Vapor Provider which makes it easy to add as a dependency.
import Vapor import VaporMustache let app = Application() //routes, etc app.providers.append(VaporMustache.Provider()) app.start()
If you don't want to use the Provider, set the
MustacheRenderer() on your
View.renderers for whatever file extensions you would like to be rendered as
import VaporMustache //set the mustache renderer //for all .mustache files View.renderers[".mustache"] = VaporZewoMustache.MustacheRenderer()
Includes let you load other mustache templates into your template with a syntax like
To use includes, you must specify them ahead of time to the
Simply add them as the Provider's
let mustache = VaporMustache.Provider(withIncludes: [ "header": "Includes/header.mustache", "footer": "Includes/footer.mustache" ]) let app = Application(providers: [mustache])
The path will be appended to
Resources/Views/... by default.
MustacheRenderer accepts a dictionary of files where the key is the include name and the value is the file path relative to the working directory.
public init(files: [String: String])