func CreateTemplateCache(pathTemplates string) (map[string]*template.Template, error) {
	tmplCache := make(map[string]*template.Template)

	layouts, err := filepath.Glob(fmt.Sprintf("%s/*.layout.html", pathTemplates))
	if err != nil {
		return tmplCache, err
	}

	pages, err := filepath.Glob(fmt.Sprintf("%s/*.page.html", pathTemplates))
	if err != nil {
		return tmplCache, err
	}

	for _, page := range pages {
		name := filepath.Base(page)

		ts, err := template.New(name).Funcs(functions).ParseFiles(page)
		if err != nil {
			return tmplCache, err
		}

		if len(layouts) > 0 {
			ts, err = ts.ParseGlob(fmt.Sprintf("%s/*.layout.html", pathTemplates))
			if err != nil {
				return tmplCache, err
			}
		}

		tmplCache[name] = ts
	}

	return tmplCache, nil
}
//CreateTemplateCache creates a template cache as a map
CreateTemplateCache creates a template cache as a map
// CreateTemplateCache creates a template cache as a map
func CreateTemplateCache(pathTemplates string) (map[string]*template.Template, error) {
	tmplCache := make(map[string]*template.Template)
	layouts, err := filepath.Glob(fmt.Sprintf("%s/*.layout.html", pathTemplates))
	if err != nil {
		return tmplCache, err
	}
	pages, err := filepath.Glob(fmt.Sprintf("%s/*.page.html", pathTemplates))
	if err != nil {
		return tmplCache, err
	}
	for _, page := range pages {
		name := filepath.Base(page)
		ts, err := template.New(name).Funcs(functions).ParseFiles(page)
		if err != nil {
			return tmplCache, err
		}
		if len(layouts) > 0 {
			ts, err = ts.ParseGlob(fmt.Sprintf("%s/*.layout.html", pathTemplates))
			if err != nil {
				return tmplCache, err
			}
		}
		tmplCache[name] = ts
	}
	return tmplCache, nil
}
func CreateTemplateCache ( pathTemplates string ) ( map [ string ] * template . Template , error ) { tmplCache := make ( map [ string ] * template . Template ) layouts , err := filepath . Glob ( fmt . Sprintf ( " " , pathTemplates ) ) if err != nil { return tmplCache , err } pages , err := filepath . Glob ( fmt . Sprintf ( " " , pathTemplates ) ) if err != nil { return tmplCache , err } for _ , page := range pages { name := filepath . Base ( page ) ts , err := template . New ( name ) . Funcs ( functions ) . ParseFiles ( page ) if err != nil { return tmplCache , err } if len ( layouts ) > 0 { ts , err = ts . ParseGlob ( fmt . Sprintf ( " " , pathTemplates ) ) if err != nil { return tmplCache , err } } tmplCache [ name ] = ts } return tmplCache , nil }
CreateTemplateCache creates a template cache as a map
CreateTemplateCache creates a template cache as a map