0

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?

Dan
  • 5,013
  • 5
  • 33
  • 59

2 Answers2

1

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.

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • 1
    There's of course always the option of putting the files into [Cloud Storage](https://cloud.google.com/storage/). – Nick Oct 13 '15 at 16:03
  • Copying files as part of a build script as @AlistairB suggests would also work. – Dan Oct 13 '15 at 18:24
  • @Nick, True, but that doesn't play very well with version-controlling the files (which are technically part of the app code) – Dan Cornilescu Aug 31 '16 at 16:12
1

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

AlistairB
  • 61
  • 1
  • 5