mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
25 lines
518 B
Go
25 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
|
||
|
}
|