dongou2019
dongou2019
2015-10-12 18:45
浏览 39
已采纳

如何在App Engine模块之间共享文件(HTML模板)?

I am using the Go runtime of Google App Engine and have two modules. I would like to share HTML templates between them but don't the best way.

My modules are organised as below:

src/github.com/myproject/moduleone/app.yaml
src/github.com/myproject/moduleone/templates/base.html
src/github.com/myproject/moduleone/templates/homeone.html

src/github.com/myproject/moduletwo/app.yaml
src/github.com/myproject/moduletwo/templates/base.html
src/github.com/myproject/moduletwo/templates/hometwo.html

In my situation base.html is the same for moduleone and moduletwo. How can I share it between both modules without having to duplicate the file as is done now?

I would like to put base.html in a directory called src/github.com/myproject/templates but I believe neither moduleone or moduletwo would be able to access the file as it's not in the same or child directory of the module app.yaml files. Is my only option to symlink the base.html file between each module's template directory?

图片转代码服务由CSDN问答提供 功能建议

我正在使用Google App Engine的Go运行时,并且有两个模块。 我想在它们之间共享HTML模板,但不是最好的方法。

我的模块结构如下:

  src  /github.com/myproject/moduleone/app.yaml
src/github.com/myproject/moduleone/templates/base.html
src/github.com/myproject/moduleone/templates/homeone.html

src/github 的.com / myproject的/ ModuleTWO中/ app.yaml中\ NSRC / github.com / myproject的/ ModuleTWO中/模板/ base.html文件\ NSRC / github.com / myproject的/ ModuleTWO中/模板/ hometwo.html 
   
 
 

在我的情况下, base.html moduleone moduletwo 相同。 我如何在两个模块之间共享它而又不必像现在那样复制文件?

我想将 base.html 放在一个名为< code> src / github.com / myproject / templates ,但我相信 moduleone moduletwo 都无法访问该文件,因为它不在同一文件中或 模块 app.yaml 文件的子目录。 我唯一的选择是在每个模块的模板目录之间符号链接 base.html 文件吗?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doukundong9652
    doukundong9652 2015-10-12 22:15
    已采纳

    GAE regards each module as a standalone application (each will run in its own GAE instance). No uploadable artifacts are shared at GAE level between the modules, each such artifact needs to be separately uploaded in each module using it.

    While other approaches are technically possible (as other mentioned) symlinking the files is IMHO the simplest solution to avoid code duplication in your own repo.

    点赞 评论
  • douguomou5094
    douguomou5094 2015-10-13 02:59

    You could copy the templates to each module as part of a build step and gitignore the copied files.

    点赞 评论

相关推荐