Standard library / html/template
html/template.Template.Parse()
Parses trusted template source and associates definitions. A syntax error is returned. Expected stdout: 'Hello Ada\n'.
Formal Syntax & Structure
go syntaxgo
func (t *Template) Parse(text string) (*Template, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| text | string | Template source text, authored by a trusted developer. |
Return Value
(*Template, error)
Parses trusted template source and associates definitions.
Working Example
Example Snippetgo
package main
import ( "fmt" "html/template" "os")
func check(e error) { if e != nil { panic(e) }}
func main() { t, e := template.New("greet").Parse("Hello {{.}}") check(e) check(t.Execute(os.Stdout, "Ada")) fmt.Println()}