Skip to content

titpetric/vuego

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vuego

Go Reference Coverage

Vuego is a Vue.js-inspired template engine for Go. Render HTML templates with familiar Vue syntax - no JavaScript runtime required.

Status

Project it in active development. Some changes in API surface are still expected based on feedback and observations.

Quick start

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:

  1. Construct new template rendering contexts with renderer.New and renderer.Load
  2. Manage state with Fill, Set and Get functions
  3. Finalize the rendering context with Render and Layout functions
  4. 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) error
  • RenderString(ctx context.Context, w io.Writer, templateStr string) error
  • RenderByte(ctx context.Context, w io.Writer, templateData []byte) error
  • RenderReader(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:

Features

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" or v-bind:attr="value"
  • Conditional rendering - v-if for showing/hiding elements with function support
  • List rendering - v-for to iterate over arrays with optional index
  • Raw HTML - v-html for unescaped HTML content
  • Component composition - <vuego include> for reusable components
  • Required props - :required attribute 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

Playground

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:3000

Documentation

The 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: