1
0
mirror of https://github.com/golang/go synced 2024-11-05 15:46:11 -07:00
go/present/html.go
Andrew Gerrand 9fc516408c go.tools/godoc/present: move present package from go.talks
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
2013-09-19 10:55:46 +10:00

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" }