我如何在App Engine模块之间共享文件(HTML模板)? [英] How can I share files (HTML templates) between App Engine modules?
问题描述
我使用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
src / github.com / myproject / moduletwo / templates /base.html
src / github.com / myproject / moduletwo / templates / hometwo.html
在我的情况下, base.html
对于 moduleone
和 moduletwo $是一样的C $ C>。如何在两个模块之间共享它,而不必像现在这样复制文件?
我想将 base.html
在一个名为
src / github.com / myproject / templates
的目录中,但我不相信 moduleone
或 moduletwo
将能够访问文件,因为它不在模块的相同或子目录中 app.yaml
文件。我的唯一选择是将每个模块的模板目录之间的 base.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?
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.
这篇关于我如何在App Engine模块之间共享文件(HTML模板)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!