Overview
Go-Mojito's Renderer interface provides a dependency-independent way to dependency inject a renderer into your handlers and middleware. By default, the built-in go template-based renderer is used, but you can easily replace it with a custom implementation like Infinytum Handlebars.
Of course you can also have multiple renderers injected by using named dependencies, even without replacing the builtin renderer.
Quick Start
-
Create a new Go-Mojito Handler that has a
mojito.RendererContext
argument.func SomeHandler(ctx mojito.RendererContext) {}
Go-Mojito will now detect that you want a renderer context injected into your handler, instead of a regular context.
Create a template in
resources/templates
calledquickstart.tpl
Hello {{.name}}
Make use of the renderer context instance
func SomeHandler(ctx mojito.RendererContext) { ctx.ViewBag().Set("name", "world") ctx.View("quickstart") }
FAQ
No frequently asked questions yet!