Giter Site home page Giter Site logo

templier's Introduction

GoReportCard

Templiér

Templiér is a Go web frontend development environment for Templ

  • Watches your .templ files and rebuilds them.
  • Watches all non-template files, rebuilds and restarts the server ✨.
  • Automatically reloads your browser tabs when the server restarts or templates change.
  • Runs golangci-lint if enabled.
  • Reports all errors directly to all open browser tabs ✨.
  • Shuts your server down gracefully.
  • Displays application server console logs in the terminal.
  • Supports templ's debug mode for fast live reload.
  • Avoids reloading when files didn't change by keeping track of hashsums.

Quick Start

Install Templiér:

go install github.com/romshark/templier@latest 

Then copy-paste example-config.yml to your project source folder as templier.yml, edit to your needs and run:

templier --config ./templier.yml

How is Templiér different from templ's own watch mode?

As you may already know, templ supports live reload out of the box using templ generate --watch --proxy="http://localhost:8080" --cmd="go run .", which is great, but Templiér provides even better developer experience:

  • 🥶 Templiér doesn't become unresponsive when the Go code fails to compile, instead it prints the compiler error output to the browser tab and keeps watching. Once you fixed the Go code, Templiér will reload and work as usual with no intervention. In contrast, templ's watcher needs to be restarted manually.
  • 📁 Templiér watches all file changes recursively (except for those that match app.exclude) and recompiles the server. Editing an embedded .json file in your app? Updating go mod? Templiér will notice and rebuild.
  • 🖥️ Templiér shows Templ, Go compiler and golangci-lint errors (if any) in the browser. Templ's watcher just prints errors to the stdout and continues to display the last valid state.
  • ⚙️ Templiér provides more configuration options (TLS, debounce, exclude globs, etc.).

How it works

Templiér acts as a file watcher, proxy server and process manager. Once Templiér is started, it runs templ generate --watch in the background and begins watching files in the app.dir-src-root directory. On start and on file change, it automatically builds your application server executable saving it in the OS' temp directory (cleaned up latest before exiting) assuming that the main package is specified by the app.dir-cmd directory. Any custom Go compiler CLI arguments can be specified by app.go-flags. Once built, the application server executable is launched with app.flags CLI parameters and the working directory set to app.dir-work. When necessary, the application server process is shut down gracefully, rebuilt, linted and restarted.

Templiér ignores changes made to .templ, _templ.go and _templ.txt files and lets templ generate --watch do its debug mode magic allowing for lightning fast reloads when a templ template changed with no need to rebuild the server.

Templiér hosts your application under the URL specified by templier-host and proxies all requests to the application server process that it launched injecting Templiér JavaScript that opens a websocket connection to Templiér from the browser tab to listen for events and reload or display necessary status information when necessary. In the CLI console logs, all Templiér logs are prefixed with 🤖, while application server logs are displayed without the prefix.

templier's People

Contributors

romshark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

templier's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.