我如何在App Engine模块之间共享文件(HTML模板)? [英] How can I share files (HTML templates) between App Engine modules?

查看:202
本文介绍了我如何在App Engine模块之间共享文件(HTML模板)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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 。如何在两个模块之间共享它,而不必像现在这样复制文件?



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

解决方案< GAE将每个模块视为一个独立的应用程序(每个模块都将在自己的GAE实例中运行)。没有可上传的工件在模块之间的GAE级别共享,每个这样的工件需要分别上传到使用它的每个模块中。

尽管其他方法在技术上是可行的提到)符号链接的文件是恕我直言的最简单的解决方案,以避免在自己的回购代码重复。


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆