mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-09 04:18:50 +03:00
24 lines
518 B
Go
24 lines
518 B
Go
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
|
|
}
|