ParseGlob: What is the pattern to parse all templates recursively within a directory?

不想你离开。 提交于 2019-12-05 21:46:10

The code text/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 patterns is the same as in Match"

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

The implementation of Match() doesn't seem to treat '**' differently, and only consider '*' as matching any sequence of non-Separator characters.
That would mean '**' is equivalent to '*', which in turn would explain why the match works at one level depth only.

So, since the ParseGlob can't load templates recursively we have to use path/filepath.Walk function. But this way gives more opportunities.

https://gist.github.com/logrusorgru/abd846adb521a6fb39c7405f32fec0cf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!