Standard library / html/template
html/template.Template.New()
Creates a named template associated with the receiver. Expected stdout: 'Hello Ada\n'.
Formal Syntax & Structure
go syntaxgo
func (t *Template) New(name string) *TemplateParameters & Attributes
| Name | Type | Description |
|---|---|---|
| name | string | Name of the template. |
Return Value
*Template
Creates a named template associated with the receiver.
Working Example
Example Snippetgo
package main
import ( "fmt" "html/template" "os")
func check(e error) { if e != nil { panic(e) }}
func main() { t := template.New("root") template.Must(t.New("greet").Parse("Hello {{.}}")) check(t.ExecuteTemplate(os.Stdout, "greet", "Ada")) fmt.Println()}