pluginsdk/templates/pagedoc.go

32 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 200599
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)
}