server

package
v0.0.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadDataFile

func LoadDataFile(contentFS fs.FS, vuegoPath string) (map[string]any, error)

LoadDataFile loads data from .yml, .yaml, or .json file accompanying a .vuego file.

func Middleware

func Middleware(contentFS fs.FS, opts ...MiddlewareOption) http.Handler

Middleware creates an http.Handler that processes .vuego files from the given filesystem. It renders .vuego files with accompanying .yml or .json data files. Non-.vuego requests are passed through to the next handler or return 404.

func MiddlewareDir

func MiddlewareDir(dir string, opts ...MiddlewareOption) http.Handler

MiddlewareDir creates an http.Handler that processes .vuego files from the given directory path. This is a convenience wrapper around Middleware that uses os.DirFS.

func Render

func Render(ctx context.Context, baseFS fs.FS, req RenderRequest, opts ...vuego.LoadOption) (string, error)

Render processes a RenderRequest and returns rendered HTML. This function can be used by both HTTP handlers and CLI commands. If the template specifies a layout in frontmatter, Layout() is used instead of Render(). This function automatically injects style links for adjacent .less/.css files.

func RenderHandler

func RenderHandler(baseFS fs.FS, opts ...vuego.LoadOption) http.HandlerFunc

RenderHandler returns an http.HandlerFunc that renders templates via POST /render. The optional baseFS provides additional files (like components) available during rendering.

Types

type MiddlewareOption

type MiddlewareOption func(*middlewareConfig)

MiddlewareOption configures the middleware behavior.

func WithLoadOption

func WithLoadOption(opt ...vuego.LoadOption) MiddlewareOption

WithLoadOption adds a LoadOption to the middleware's Vue instance.

type RenderRequest

type RenderRequest struct {
	Template string            `json:"template"`
	Data     string            `json:"data"`
	Files    map[string]string `json:"files,omitempty"`
}

RenderRequest contains template and data for rendering.

type RenderResponse

type RenderResponse struct {
	HTML  string `json:"html,omitempty"`
	Error string `json:"error,omitempty"`
}

RenderResponse contains the rendered HTML or an error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL