LiveTemplate Examples

Example applications demonstrating LiveTemplate usage with various features and patterns.

Showcase: Todo App

The todo app demonstrates LiveTemplate's core features in ~150 lines of Go + ~80 lines of HTML:

Progressive Complexity

All examples follow the progressive complexity model. Tier 1 (standard HTML) is preferred; Tier 2 (lvt-* attributes) is used only when necessary.

Example Tier Description Tier 2 Attributes
counter/ 1 Counter with logging + graceful shutdown None
chat/ 1+2 Real-time multi-user chat lvt-fx:scroll
todos/ 1+2 Full CRUD with SQLite, auth, modal + toast components lvt-on:change, lvt-fx:animate, lvt-fx:highlight, lvt-el:setAttr
flash-messages/ 1 Flash notification patterns None
avatar-upload/ 1+2 File upload with progress lvt-upload
progressive-enhancement/ 1 Works with/without JS None
ws-disabled/ 1 HTTP-only mode None
live-preview/ 1 Change() live updates None
login/ 1+2 Authentication + sessions lvt-form:no-intercept
shared-notepad/ 1+2 BasicAuth + SharedState lvt-form:preserve
dialog-patterns/ 1 Native <dialog> with command/commandfor None (polyfilled by client)

Examples

The directories listed in the table above are individual example applications. Each folder contains a minimal, self-contained project that demonstrates a specific LiveTemplate pattern or feature.

Running Examples

Each example is self-contained with its own go.mod. To run an example:

cd <example-directory>
go mod download
go run main.go

Testing Examples

Test All Examples

Run all working examples at once:

./test-all.sh

This script will:

Test Individual Example

Examples include E2E tests using Chromedp:

cd <example-directory>
go test -v

CI/CD

The test script is also used in GitHub Actions. See .github/workflows/test.yml for CI configuration.

Using the Client Library

Production (CDN)

Examples are configured to use the CDN version of the client library:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@livetemplate/client@latest/livetemplate.css">
<script defer src="https://cdn.jsdelivr.net/npm/@livetemplate/client@latest/dist/livetemplate-client.browser.js"></script>

Development (Local)

For local development, examples can serve the client library locally using github.com/livetemplate/lvt/testing.

Dependencies

Version Synchronization

Examples follow the LiveTemplate core library's major.minor version:

Contributing

See CONTRIBUTING.md for guidelines on adding new examples.

License

MIT License - see LICENSE for details.