Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Render ¶
Render is a struct that contains the configuration for the renderer.
func (*Render) GoPage ¶
func (c *Render) GoPage(w http.ResponseWriter, r *http.Request, view string, data interface{}) error
GoPage is a method on the Render struct that renders a Go template page. It takes a http.ResponseWriter, http.Request, a string representing the view, and an interface{} for data. The method first attempts to parse the template file corresponding to the view. If an error occurs during parsing, it returns the error. If the data passed is not nil, it asserts the data to be of type *TemplateData. It then executes the template with the TemplateData and writes the output to the http.ResponseWriter.
func (*Render) Page ¶
func (c *Render) Page(w http.ResponseWriter, r *http.Request, view string, variables, data interface{}) error
Page renders a web page using the specified view and data. It selects the rendering engine based on the Renderer's value.
Parameters:
- w: The HTTP response writer.
- r: The HTTP request.
- view: The name of the view template to render.
- variables: Additional variables for rendering (currently unused).
- data: The data to pass to the view template.
Returns:
- error: An error if the rendering fails, otherwise nil.
type TemplateData ¶
type TemplateData struct {
IsAuthenticated bool
IntMap map[string]int
StringMap map[string]string
FloatMap map[string]float32
Data map[string]interface{}
CSRFToken string
Port string
ServerName string
Secure bool
}
TemplateData is a struct that contains the data to be passed to the template.