Documentation
¶
Overview ¶
Package render provides Pine's built-in HTML template engine.
Call Setup once after creating a server to install the engine and, when Config.ReloadTemplates is true, start automatic hot-reloading:
app := pine.New(pine.Config{ViewPath: "views", ReloadTemplates: true})
if err := render.Setup(app); err != nil {
log.Fatal(err)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LiveReload ¶
LiveReload wires up template hot-reloading for development.
It registers a WebSocket endpoint at "/__pine_reload" that browser clients connect to. A file watcher (powered by websocket.Watch) monitors server.ViewPath() for template changes. On each change it:
- Calls engine.Rebuild() to re-parse all templates on the server side.
- Broadcasts a "reload" frame to every connected browser tab.
Engine.Render() detects that live reload is active and automatically injects a tiny inline <script> into every HTML response — no template changes needed.
LiveReload is called automatically by Setup() when server.ReloadTemplates() is true — there is no need to call it explicitly.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is Pine's HTML template engine. It implements pine.ViewEngine and pine.Reloader using Go's html/template package. All fields are safe for concurrent use.
func New ¶
New creates and returns a new Engine pre-loaded with all templates found under viewPath. Supported extensions: .html, .gohtml, .tmpl. Each template is named by its path relative to viewPath with forward-slash separators, e.g. "index.html" or "admin/dashboard.html".