32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
package templates
|
||
|
||
import (
|
||
"context"
|
||
"io"
|
||
|
||
"git.dev.alexdunmow.com/block/pluginsdk/document"
|
||
)
|
||
|
||
// 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
|
||
StatusCode int32 // requested HTTP status; host accepts 200–599
|
||
Metadata *document.Metadata
|
||
}
|
||
|
||
func (p *PageDocument) Render(ctx context.Context, w io.Writer) error {
|
||
if p.Body == nil {
|
||
return nil
|
||
}
|
||
return p.Body.Render(ctx, w)
|
||
}
|