godoc'd the source
This commit is contained in:
+15
-2
@@ -6,6 +6,8 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
// Package ui holds the support for the Amsterdam user interface, wrapping Echo and Jet templates.
|
||||
package ui
|
||||
|
||||
import (
|
||||
@@ -16,18 +18,29 @@ import (
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// views is the main Jet template repository.
|
||||
var views = jet.NewSet(
|
||||
jet.NewOSFileSystemLoader("./views"),
|
||||
jet.DevelopmentMode(true),
|
||||
)
|
||||
|
||||
// init adds additional configuration for the views object.
|
||||
func init() {
|
||||
views.AddGlobal("GlobalConfig", config.GlobalConfig)
|
||||
}
|
||||
|
||||
type TemplateRenderer struct {
|
||||
}
|
||||
// TemplateRenderer is the Renderer instance set into the Echo context at creation time, to render Jet templates.
|
||||
type TemplateRenderer struct{}
|
||||
|
||||
/* Render renders a Jet template to the Echo output stream.
|
||||
* Parameters:
|
||||
* w - Echo's output stream writer.
|
||||
* name - Name of the template to be rendered.
|
||||
* data - Context data to pass to the template.
|
||||
* c - The Echo context for the request being processed.
|
||||
* Returns:
|
||||
* Standard Go error status.
|
||||
*/
|
||||
func (r *TemplateRenderer) Render(w io.Writer, name string, data any, c echo.Context) error {
|
||||
view, err := views.GetTemplate(name)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user