improve package gview

This commit is contained in:
John Guo
2022-03-10 09:48:19 +08:00
parent e3f0163092
commit f5693c4393

View File

@ -60,7 +60,7 @@ var (
// and returns the parsed template content.
func (view *View) Parse(ctx context.Context, file string, params ...Params) (result string, err error) {
var tpl interface{}
// It caches the file, folder and its content to enhance performance.
// It caches the file, folder and content to enhance performance.
r := view.fileCacheMap.GetOrSetFuncLock(file, func() interface{} {
var (
path string
@ -272,10 +272,9 @@ func (view *View) getTemplate(filePath, folderPath, pattern string) (tpl interfa
}
}
// Secondly checking the file system.
var (
files []string
)
// Secondly checking the file system,
// and then automatically parsing all its sub-files recursively.
var files []string
files, err = gfile.ScanDir(folderPath, pattern, true)
if err != nil {
return nil