Skip to content

include view templates in builds - #13

Merged
itsharrykim merged 1 commit into
mainfrom
codex/include-templates-in-build
Jun 16, 2026
Merged

include view templates in builds#13
itsharrykim merged 1 commit into
mainfrom
codex/include-templates-in-build

Conversation

@itsharrykim

Copy link
Copy Markdown
Collaborator

This pull request migrates both the main and admin template and static file loading to use Go's embed.FS for embedding files into the binary, replacing all filesystem access with embedded resources. This improves deployment simplicity and reliability, as all required assets are now part of the compiled application. Additionally, tests are added to ensure templates are correctly loaded from the embedded filesystem.

Template and static file embedding:

  • Added embed.FS variables (TemplateFiles, StaticFiles, and ViewFiles) to gojang/views/templates.go and gojang/admin/admin_renderer.go to embed templates and static files into the binary. [1] [2]
  • Refactored template loading in gojang/views/renderers/renderer.go and gojang/admin/admin_renderer.go to read from embedded files instead of disk, using fs.WalkDir and ReadFile. [1] [2] [3] [4] [5] [6]
  • Updated static file serving in gojang/cmd/web/main.go to use embedded filesystems for both main and admin static assets, replacing http.Dir with http.FS.

Testing:

  • Added tests to gojang/views/renderers/renderer_test.go and gojang/admin/admin_renderer_test.go to verify that templates are loaded from the embedded filesystem and that partials are included as expected. [1] [2]

Code cleanup:

  • Removed unused imports and code related to direct filesystem access (os, filepath) in renderer files. [1] [2]

These changes make the application fully self-contained with respect to templates and static assets, improving portability and reducing deployment errors.

@itsharrykim
itsharrykim merged commit 8e594b7 into main Jun 16, 2026
1 check passed
@itsharrykim
itsharrykim deleted the codex/include-templates-in-build branch June 16, 2026 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant