bastianwegge / templ-playground

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

xc compatible

Templ Playground

This project is a templ playground, using WebAssembly (WASM) application to convert Templ templates into Go code and execute them in the go playground, Rendering the result to the user.

Templ playground in action

How to Use

  1. Run the xc build-wasm command (If not installed see XC documentation here).
  2. Run the xc serve command (If not installed see XC documentation here).
  3. Navigate to localhost:8080
  4. Write your Templ code in the editor.
  5. Click the "Run" button to convert the Templ code into Go code.
  6. The HTML code will be displayed in the bottom left editor.
  7. The rendered result on the bottom left preview panel.

Dependencies

Templ: A library for generating Go code from Templ templates. CodeMirror: A versatile text editor implemented in JavaScript for the browser.

Tasks

build-wasm

Builds templ to go converter wasm module

GOOS=js GOARCH=wasm go build -o public/main.wasm ./templtogo

install

Install dev dependencies.

go install github.com/a-h/serve@main

serve

Runs a simple web server for local playground development

serve -dir ./public

About


Languages

Language:JavaScript 60.7%Language:HTML 18.7%Language:CSS 14.0%Language:Go 6.6%