mirror of
https://github.com/golang/go
synced 2024-11-05 15:56:12 -07:00
9fc516408c
Godoc depends on go.talks/pkg/present by way of go.tools/pkg/blog. Better to keep all godoc dependencies in one place. R=golang-dev, dsymonds, r CC=golang-dev https://golang.org/cl/13656047
32 lines
563 B
Go
32 lines
563 B
Go
package present
|
|
|
|
import (
|
|
"errors"
|
|
"html/template"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
func init() {
|
|
Register("html", parseHTML)
|
|
}
|
|
|
|
func parseHTML(ctx *Context, fileName string, lineno int, text string) (Elem, error) {
|
|
p := strings.Fields(text)
|
|
if len(p) != 2 {
|
|
return nil, errors.New("invalid .html args")
|
|
}
|
|
name := filepath.Join(filepath.Dir(fileName), p[1])
|
|
b, err := ctx.ReadFile(name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return HTML{template.HTML(b)}, nil
|
|
}
|
|
|
|
type HTML struct {
|
|
template.HTML
|
|
}
|
|
|
|
func (s HTML) TemplateName() string { return "html" }
|