Documentation ¶
Overview ¶
Package render implements template inheritance and exposes functions to render HTML.
inspired by http://elithrar.github.io/article/approximating-html-template-inheritance and https://github.com/sourcegraph/thesrc/blob/master/app/handler.go
It also exports two types Binary and HMTL. Both wrap a http.HandlerFunc-like function with an error return value and argument the response.
Index ¶
- func PlainError(w http.ResponseWriter, r *http.Request, statusCode int, err error)
- type Binary
- type FuncInjector
- type Option
- type RenderFunc
- type Renderer
- func (r *Renderer) Error(w http.ResponseWriter, req *http.Request, status int, err error)
- func (r *Renderer) GetReloader() func(http.Handler) http.Handler
- func (r *Renderer) HTML(name string, f RenderFunc) http.HandlerFunc
- func (r *Renderer) Reload() error
- func (r *Renderer) Render(w http.ResponseWriter, req *http.Request, name string, status int, ...) error
- func (r *Renderer) StaticHTML(name string) http.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PlainError ¶
PlainError helps rendering user errors
Types ¶
type Binary ¶
type Binary func(resp http.ResponseWriter, req *http.Request) error
Binary sets Content-Description and Content-Transfer-Encoding if h returns an error it returns http status 500
type FuncInjector ¶ added in v1.6.0
type Option ¶
func AddTemplates ¶
AddTemplates adds filenames for the next call to parseTempaltes
func BaseTemplates ¶
func InjectTemplateFunc ¶ added in v1.6.0
func InjectTemplateFunc(name string, fn FuncInjector) Option
type RenderFunc ¶
type RenderFunc func(w http.ResponseWriter, req *http.Request) (interface{}, error)
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
func New ¶
func New(fs http.FileSystem, opts ...Option) (*Renderer, error)
New creates a new Renderer
func (*Renderer) HTML ¶
func (r *Renderer) HTML(name string, f RenderFunc) http.HandlerFunc
Click to show internal directories.
Click to hide internal directories.