ParseGlob:在目录内递归解析所有模板的模式是什么? [英] ParseGlob: What is the pattern to parse all templates recursively within a directory?
问题描述
Template.ParseGlob(*。html)//从当前目录获取所有html文件。
Template.ParseGlob(** / *。html)//似乎只在一级深度获取
我不在寻找漫步解决方案。只是想知道这是否可能。我不太明白这个预期的模式。如果我能得到一个关于ParseGlob使用的模式的解释,那就太好了。
code text / template / helper.go
提及 //该模式由filepath.Glob处理,并且必须至少匹配一个文件。
如果名称与shell文件名称模式匹配,匹配返回true。 Match()的实现似乎不是以不同的方式处理' filepath.Glob()
表示模式的语法与
**
',只考虑' *
'作为匹配任何非分隔符字符序列。
这意味着' **
'相当于' *
',这反过来可以解释为什么匹配只能在一个级别深度进行。
Template.ParseGlob("*.html") //fetches all html files from current directory.
Template.ParseGlob("**/*.html") //Seems to only fetch at one level depth
Im not looking for a "Walk" solution. Just want to know if this is possible. I don't quite understand what "pattern" this expects. if i can get an explanation about the pattern used by ParseGlob that would be great too.
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.
这篇关于ParseGlob:在目录内递归解析所有模板的模式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!