Created
September 17, 2016 02:55
-
-
Save asit-dhal/fc7fe51e3b2014d459a4f1e32c747abd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"html/template" | |
"os" | |
) | |
var templateDemo = ` | |
{{ define "a" }} | |
Template A includes Template B | |
{{ block "b" .}} Template B {{ end }} | |
Template A ends | |
{{ end }} | |
` | |
func main() { | |
var err error | |
t := template.New("templateActionDemo") | |
t, err = t.Parse(templateDemo) | |
if err != nil { | |
fmt.Println("parsing failed: %s", err) | |
} | |
err = t.ExecuteTemplate(os.Stdout, "a", nil) | |
if err != nil { | |
fmt.Println("execution failed: %s", err) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Template A includes Template B | |
Template B | |
Template A ends |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment