Skip to content

text/template: improve error message about empty/incomplete templates after Funcs() #4522

@kylelemons

Description

@kylelemons
The error message is here:
http://golang.org/src/pkg/text/template/exec.go#L115

I've noticed that this has caused problems for people both on the mailing list and on
IRC.  This often comes up with respect to template.Funcs, where you suddenly have to
create an empty template before you can attach functions to it.

Possible improvements:
- say "did you mean to call ExecuteTemplate?"
- include a list of complete templates that do exist in the template set
- provide a top-level Funcs() function that returns a template on which ParseFiles has
its top-level effect of causing the first template to be selected on Execute
- explain a bit more what's going on in the documentation for the functions above, and
add examples

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions