Documentation ¶
Overview ¶
Package render contains utility functions that make it easier to render content in a web service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileRenderer ¶
type FileRenderer struct {
// contains filtered or unexported fields
}
FileRenderer is a renderer that can be used to render files (as opposed to HTML pages) in a embedded FS. Note that this only supports individual file templates and does not support componentization.
func NewFileRenderer ¶
func NewFileRenderer(logger *zap.Logger, opts FileRendererOpts) (*FileRenderer, error)
NewFileRenderer will load the file templates from the views FS and load each template as a named template by its path.
func (FileRenderer) RenderFile ¶
func (r FileRenderer) RenderFile(tplPath string, data interface{}) (string, error)
RenderFile will render the file template at the given path using the provided data.
type FileRendererOpts ¶
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
func NewRenderer ¶
func NewRenderer(logger *zap.Logger, opts RendererOpts) (*Renderer, error)
NewRenderer will load the templates from the views FS and load each page template as a named template by its path. Note that every template will include all the templates from the layouts and components folder so that cross references work, but NOT individual pages. This means that a page template can reference components and layouts with a template directive, but will not be able to load templates from another page.