28 lines
931 B
Go
28 lines
931 B
Go
package templates
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
)
|
|
|
|
// PageDocument is a full-page template's contribution to the document. The
|
|
// HOST owns the envelope (doctype/<html>/<head>/<body> and the bn chrome);
|
|
// the guest supplies the body interior and envelope attributes. PageDocument
|
|
// is itself an HTMLComponent (renders Body), so TemplateFunc's signature is
|
|
// unchanged and non-page callers need no adaptation.
|
|
type PageDocument struct {
|
|
Body HTMLComponent
|
|
BodyClass string
|
|
Lang string // <html lang>; empty means host default "en"
|
|
HTMLAttrs map[string]string // extra <html> attributes (e.g. data-theme)
|
|
HeadExtra HTMLComponent // appended inside <head> after bn.Head
|
|
BodyEndExtra HTMLComponent // appended before </body> after bn.BodyEnd
|
|
}
|
|
|
|
func (p *PageDocument) Render(ctx context.Context, w io.Writer) error {
|
|
if p.Body == nil {
|
|
return nil
|
|
}
|
|
return p.Body.Render(ctx, w)
|
|
}
|