【发布时间】:2014-07-30 15:25:05
【问题描述】:
我正在开发一个 Google App Engine Go 应用程序,并且需要在我的一个包中使用一些 HTML 模板。当前文件结构为:
GOPATH/github.com/NAME/PROJECT/
app/
app.go
app.yaml
package/
package.go
Templates/
Template.html
为了包含这个包,我使用:
导入“github.com/NAME/PROJECT/package”
在 package.go 内部,我尝试以各种方式解析我的 Template.html 文件:
//Template, err := template.ParseFiles("package/Templates/Template.html") //doesn't work - "The system cannot find the path specified."
//Template, err := template.ParseFiles("github.com/NAME/PROJECT/package/Templates/Template.html") //doesn't work - "The system cannot find the path specified."
//Template, err := template.ParseFiles("Templates/Template.html") //doesn't work - "The system cannot find the path specified."
//Template, err := template.ParseFiles("/Templates/Template.html") //doesn't work - "The system cannot find the path specified."
Template, err := template.ParseFiles("../package/Templates/Template.html") //works on desktop!
所以我选择了适用于我的桌面测试环境的最后一个选项,将其上传到 AppEngine,然后我收到“不允许操作”的新错误...
如何解析具有如上所示文件配置的 HTML 模板,该模板既适用于 App Engine,也适用于桌面?
【问题讨论】:
标签: html google-app-engine templates path go