Documentation
¶
Overview ¶
httpview is a helper library to increase code reusability in other projects It is useful for streamlining rendering HTML and text templates. Inspired by https://www.calhoun.io/intro-to-templates-p4-v-in-mvc/
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
Executes chosen named template and writes it to provided io.Writer. This is the default way of executing templates in this library.
func NewViewData ¶
Sets a user-defined function that returns standard struct passed to every template. It should accept HTTP request, HTML title and data for additional template values.
func SetLayoutDir ¶
func SetLayoutDir(dir string)
Sets layout directory where the template base files are stored. All of this template files are included in each template.
Types ¶
type Tmpl ¶
Type for holding template configurations (Views)
var Templates Tmpl
Global variable for holding template configurations (Views)
type View ¶
View holds template configuration
func NewViewHtml ¶
Creates new View named layoutName as HTML Template
func NewViewText ¶
Creates new View named layoutName as Text Template
func (*View) RenderHtml ¶
Renders HTML Template from View to io.Writer using custom data struct
func (*View) RenderText ¶
Renders Text Template from View to io.Writer using custom data struct
func (*View) SetViewHtml ¶
Sets HTML Template to existing View
func (*View) SetViewText ¶
Sets Text Template to existing View