英文:
Golang parsing template from third party lib
问题
我正在编写一个库,该库从其模板包中解析模板。当我在示例应用程序中使用它时,它会从自己的目录中读取模板,但库中的代码失败了。
这是库的链接-https://github.com/bangarharshit/bigpipe-golang,我在这一行遇到了问题-https://github.com/bangarharshit/bigpipe-golang/blob/master/Application.go#L66
从库中复制的代码:
templates, err := template.ParseFiles("templates/bigpipe.html")
if err != nil {
return
}
英文:
I am writing a library which is parsing templates from its template package. When I am using it within a sample application its reading the template from its own directory but the code in libary is failing.
Here is the libary - https://github.com/bangarharshit/bigpipe-golang and I am facing issues with this line - https://github.com/bangarharshit/bigpipe-golang/blob/master/Application.go#L66
Copying code from lib -
templates, err := template.ParseFiles("templates/bigpipe.html")
if err != nil {
return
}
答案1
得分: 0
一种替代方案是将文件内容复制到一个变量中,然后使用template.parse而不是template.parsefiles。
英文:
One alternative soultion is to copy content from file into a variable and use template.parse instead of template.parsefiles
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论