templ icon indicating copy to clipboard operation
templ copied to clipboard

Proposal: create a templ init comand to create a starter website

Open a-h opened this issue 2 years ago • 3 comments

The starter website might have:

  • /scripts - TypeScript or ES6 in here would be transpiled by esbuild.
    • package.json - To enable the use of 3rd party JavaScript packages.
    • default.ts - Will end up in the scripts/dist directory as default.js.
  • /routes
    • /default
      • default.templ - Template for the / page.
      • default.go - HTTP handler for /.
    • /about
      • about.templ - Template for the /about page.
      • about.go - HTTP handler for /about.
    • /register
      • register.templ - Template for the /register page.
      • register.go - HTTP handler for /register.
  • router.go - provides a router.
  • /layout
    • /global
      • page.templ - Overall template
      • header.templ - Header template
      • footer.templ - Footer template
  • /static
    • logo.png - image to include.
  • main.go - Entry point that runs everything as a web server.
  • README.md - includes tasks that demonstrate how to run everything, including templ generate, esbuild operations, hot reload.

Ideally, it would also have a way to output a CDK compatible version for AWS hosting, and maybe include a Github Actions or similar way of building.

Maybe there's a template project builder that can be applied for this purpose?

a-h avatar Mar 20 '22 17:03 a-h

This could be done via the go new command now, just needs a go new compatible template repo to be created.

joerdav avatar Sep 06 '23 17:09 joerdav

Is there anything fixed for the go new command? I only found https://github.com/golang/go/discussions/61669

cugu avatar Oct 29 '23 12:10 cugu

Nothing fixed, I think the thread you found is where it's up to.

a-h avatar Oct 29 '23 21:10 a-h

@a-h i am trying to do that by creating https://github.com/gozinc/zinc

KunalSin9h avatar Jan 10 '24 08:01 KunalSin9h

And there is also https://github.com/anthdm/slick A fair few people have some templates to scaffold their preferred stack.

joerdav avatar Jan 10 '24 08:01 joerdav

Marking this as needs decision, whether or not we will do something for this.

joerdav avatar Jan 31 '24 09:01 joerdav

The repo https://github.com/Melkeydev/go-blueprint had added an option for a templ/htmx starter project. An option could be to mention it in the docs.

JonnyLoughlin avatar Jan 31 '24 21:01 JonnyLoughlin

Okay, yes I agree. A list of starter projects and what they provide could be sufficient for now. Will put this as needs fix, for if someone would like to start the list in the docs.

joerdav avatar Feb 01 '24 08:02 joerdav