Skip to content

Commit

Permalink
doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stanistan committed Dec 4, 2023
1 parent 3588374 commit 2b70959
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions renderable.go
Expand Up @@ -5,17 +5,25 @@ import (
"html/template"
)

// Renderable represents any struct that can be rendered
// in the Render function.
type Renderable interface {
// Template provides the template object / parsed and compiled,
// that Render will execute given a context.
Template(ctx context.Context) (*template.Template, error)
// TemplateData provides the data to the template given a context.
TemplateData(ctx context.Context) (any, error)
}

type AsRenderable interface {
// Renderable produces a Renderable struct given a context.
Renderable(ctx context.Context) (Renderable, error)
}

// RenderableFunc is a function that conforms to the Renderable interface.
type RenderableFunc func(context.Context) (Renderable, error)

// Renderable implements Renderable for RenderableFunc.
func (f RenderableFunc) Renderable(ctx context.Context) (Renderable, error) {
return f(ctx)
}

0 comments on commit 2b70959

Please sign in to comment.