You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
563 B

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