Vuego is a Vue.js-inspired template engine for Go. Render HTML templates with familiar Vue syntax - no JavaScript runtime required.
Project it in active development. Some changes in API surface are still expected based on feedback and observations.
You can use vuego by importing it in your project:
import "github.com/titpetric/vuego"
In your service you create a new vuego renderer.
renderer := vuego.New(
vuego.WithFS(os.DirFS("templates")),
vuego.WithFuncs(funcMap),
),With this you have a vuego.Template. From here you can:
- Construct new template rendering contexts with renderer.New and renderer.Load
- Manage state with
Fill,SetandGetfunctions - Finalize the rendering context with
RenderandLayoutfunctions - Additional renderers are provided to render from non-FS sources
An example of a rendering invocation would be:
err = renderer.File(filename).Fill(data).Layout(r.Context(), w)Layout will use front-matter layout hints to load layouts from layouts/%s.vuego. If no hint is provided, layouts/base.vuego is passed the contents from the previously rendered template. Use Render if you don't want layouts.
For rendering fragments (from variables or otherwise):
RenderFile(ctx context.Context, w io.Writer, filename string) errorRenderString(ctx context.Context, w io.Writer, templateStr string) errorRenderByte(ctx context.Context, w io.Writer, templateData []byte) errorRenderReader(ctx context.Context, w io.Writer, r io.Reader) error
An example of a rendering invocation is:
err = renderer.New().Fill(data).RenderString(r.Context(), w, `<li v-for="item in items">{{ item.title }}</li>`.There's more detail around authoring vuego templates, check documentation:
Vuego supports the following template features:
- Variable interpolation -
{{ variable }}with nested property access - Template functions - Pipe-based filter chaining
{{ value | upper | trim }} - Custom functions - Define custom template functions (FuncMap)
- Built-in filters - String manipulation, formatting, type conversion
- Attribute binding -
:attr="value"orv-bind:attr="value" - Conditional rendering -
v-iffor showing/hiding elements with function support - List rendering -
v-forto iterate over arrays with optional index - Raw HTML -
v-htmlfor unescaped HTML content - Component composition -
<vuego include>for reusable components - Required props -
:requiredattribute for component validation - Template wrapping -
<template>tag for component boundaries - Full documents - Support for complete HTML documents or fragments
- Automatic escaping - Built-in XSS protection for interpolated values
Try VueGo in your browser! The interactive playground lets you experiment with templates and see results instantly.
You can run the playground locally, and if you pass a folder as the first parameter, you have a workspace.
# go run github.com/titpetric/vuego/cmd/vuego-playground
2025/11/14 20:07:31 VueGo Playground starting on http://localhost:3000The Template Syntax reference covers four main areas:
- Values - Variable interpolation, expressions, and filters
- Directives - Complete reference of all
v-directives - Components -
<vuego>and<template>tags - Advanced - Template functions, custom filters, and full documents
Additional resources:
- FuncMap & Filters - Custom template functions and built-in filters
- Components Guide - Detailed component composition examples
- Testing - Running tests and interpreting results
- CLI Usage - Command-line tool reference
- Concurrency - Thread-safety and concurrent rendering