func/templates
Lance Ball 166313b541
improve template comments for Node.js and TypeScript (#902)
* improve template comments for Node.js and TypeScript

See: https://github.com/knative-sandbox/kn-plugin-func/issues/572

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: add zz_ file

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: whitespace

Signed-off-by: Lance Ball <lball@redhat.com>
2022-03-15 15:36:59 -07:00
..
go Adding sample function in go template (#840) 2022-03-01 07:38:42 -08:00
node improve template comments for Node.js and TypeScript (#902) 2022-03-15 15:36:59 -07:00
python chore: update manifest.yamls (#846) 2022-02-22 09:10:04 -08:00
quarkus chore: update boson builder image references (#810) 2022-02-02 05:06:33 -08:00
rust chore: update manifest.yamls (#846) 2022-02-22 09:10:04 -08:00
springboot Updating to latest spring cloud release and refactoring code (#838) 2022-03-11 07:22:32 -08:00
typescript improve template comments for Node.js and TypeScript (#902) 2022-03-15 15:36:59 -07:00
README.md Update wrt switch from pkger to custom ZIP pkging (#889) 2022-03-09 17:39:46 -08:00
manifest.yaml feat: add support for manifest.yaml at repo/language/template levels (#558) 2021-10-27 07:09:01 -07:00

README.md

Templates

Packaging

When updates are made to these templates, they must be packaged (serialized as a Go byte array) by running make zz_filesystem_generated.go, and checking in the resultant zz_filesystem_generated.go file.

How it works

The ./generate/templates directory contains Go program that generates zz_filesystem_generated.go. The file defines byte array variable named templatesZip. The variable contains ZIP representation of the templates directory. The byte array variable is then used to instantiate exported global variable function.EmbeddedTemplatesFS, which implements standard Go interfaces fs.ReadDirFS and fs.StatFS.

Rationale

Until such time as embedding static assets in binaries is included in the base go build functionality (see https://github.com/golang/go/issues/35950) we need to use our custom serialization script (./generate/templates/main.go).

Native Go embedding introduced in Go 1.16 could be used for executable binary, however it cannot be used for library. For a library we need to generate a Go source code containing the templates.