0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00
caddy/middleware/templates/context.go

25 lines
518 B
Go
Raw Normal View History

package templates
import (
"io/ioutil"
"net/http"
)
// This file contains the context and functions available for
// use in the templates.
// context is the context with which templates are executed.
type context struct {
root http.FileSystem
}
// Include returns the contents of filename relative to the site root
func (c context) Include(filename string) (string, error) {
file, err := c.root.Open(filename)
if err != nil {
return "", err
}
body, err := ioutil.ReadAll(file)
return string(body), err
}