Beispiel #1
0
func processPageTemplate(filename string, tree *parse.Tree) {
	// Prefix ~ template names with the file name.
	// ~ denotes a template used as a master page content section.
	// We prefix these with the file name to prevent 'redefinition of template'
	// errors when we store all of the templates from multiple files
	// in the same template set.
	if strings.HasPrefix(tree.Name, "~") {
		tree.Name = filename + tree.Name
	}
	if strings.HasPrefix(tree.ParseName, "~") {
		tree.ParseName = filename + tree.ParseName
	}
	fmt.Printf("\tdefine: %s\n", tree.Name)

	// Iterate the parse tree and update any
	// {{template "~..."}} nodes to use the file name prefix.
	prefixTildeTemplates(filename, tree.Root.Nodes)
}