github.com/jgarto/itcv@v0.0.0-20180826224514-4eea09c1aa0d/_vendor/src/golang.org/x/tools/present/html.go (about)

     1  package present
     2  
     3  import (
     4  	"errors"
     5  	"html/template"
     6  	"path/filepath"
     7  	"strings"
     8  )
     9  
    10  func init() {
    11  	Register("html", parseHTML)
    12  }
    13  
    14  func parseHTML(ctx *Context, fileName string, lineno int, text string) (Elem, error) {
    15  	p := strings.Fields(text)
    16  	if len(p) != 2 {
    17  		return nil, errors.New("invalid .html args")
    18  	}
    19  	name := filepath.Join(filepath.Dir(fileName), p[1])
    20  	b, err := ctx.ReadFile(name)
    21  	if err != nil {
    22  		return nil, err
    23  	}
    24  	return HTML{template.HTML(b)}, nil
    25  }
    26  
    27  type HTML struct {
    28  	template.HTML
    29  }
    30  
    31  func (s HTML) TemplateName() string { return "html" }