ParseGlob: What is the pattern for parsing all patterns recursively within a directory?

Template.ParseGlob("*.html") //fetches all html files from current directory.
Template.ParseGlob("**/*.html") //Seems to only fetch at one level depth

      

I am not looking for a "Walk" solution. I just want to know if this is possible. I am not quite sure what "template" expects this. if I can get an explanation about the pattern used by ParseGlob that would be great too.

+3


source to share


1 answer


codetext/template/helper.go

mentions

 // The pattern is processed by filepath.Glob and must match at least one file.

      

filepath.Glob()

says that "the syntax of templates is the same as in " Match



Match returns true if the name matches the shell filename pattern.

the implementation of Match () seems to have different meanings to ' **

' and treats " *

" as matching any sequence of non-separator characters.
This means "is **

" equivalent to " *

", which in turn explains why the match only works at a depth of one level.

+5


source







All Articles