You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
831 B

package engine
import (
func NewEncode(name string, encode func(w io.Writer, data interface{}) error, ext ...mime.Ext) Encode {
return Encode{
name: name,
encode: encode,
formats: ext,
type Encode struct {
encode func(w io.Writer, data interface{}) error
name string
formats []mime.Ext
func (e Encode) Support(_ context.Context, reference render.Reference) bool {
return Support(reference,, e.formats...)
func (e Encode) Load(context.Context, render.Reference) (render.Execute, error) {
return func(_ context.Context, wr io.Writer, data interface{}, _ render.Params) error {
if err := e.encode(wr, data); err != nil {
return fmt.Errorf("%s engine:%w",, err)
return nil
}, nil