Documentation ¶
Overview ¶
Package ginraymond is a custom template renderer that can be used with the Gin web framework: https://github.com/gin-gonic/gin, it adds support for Handlebars style templates to your Gin application. It uses the Raymond template library for this: https://github.com/aymerick/raymond, which implements Handlebars style templates in pure Go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadTemplate ¶
LoadTemplate always loads the template from disk.
func MustLoadTemplate ¶
MustLoadTemplate loads the template from disk and panics on error.
Types ¶
type RaymondRender ¶
type RaymondRender struct { Options *RenderOptions Cache *TemplateCache Template *raymond.Template Context interface{} }
RaymondRender is a custom Gin template renderer using Raymond.
func Default ¶
func Default() *RaymondRender
Default creates a RaymondRender instance with default options.
func New ¶
func New(options *RenderOptions) *RaymondRender
New creates a new RaymondRender instance with custom Options.
func (RaymondRender) Instance ¶
func (r RaymondRender) Instance(name string, data interface{}) render.Render
Instance should return a new RaymondRender struct for the current request and prepare the *raymond.Template that will be used for this response. Because of GIN's design, the Instance method cannot return an error type. This means that we have to panic on any errors which is not ideal in Go.
func (RaymondRender) Render ¶
func (r RaymondRender) Render(w http.ResponseWriter) error
Render should render the template to the response.
type RenderOptions ¶
RenderOptions is used to configure the renderer.
func DefaultOptions ¶
func DefaultOptions() *RenderOptions
DefaultOptions constructs a RenderOptions struct with default settings.
type TemplateCache ¶
type TemplateCache struct { TemplateDir string // contains filtered or unexported fields }
TemplateCache manages a cache for raymond templates.