renderer

package
v0.1.0-alpha.74 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package renderer evaluates GoBeyond rendering plans and emits deterministic HTML without executing JavaScript.

Index

Constants

View Source
const FrameworkLocalsKey = "__gobeyond"

FrameworkLocalsKey is the reserved locals namespace used by portable usePathname / useRoute bake paths (`__gobeyond.pathname`, `__gobeyond.route`).

Variables

This section is empty.

Functions

func Render

func Render(plan *renderplan.Plan, props any) (string, error)

Render validates and renders a complete plan. It never returns partial HTML. The render clock is captured once and must also be embedded in hydration data as renderNow so browser Date rewrites match Go (same class of contract as Next.js SSR: first paint uses the server snapshot).

func RenderAt

func RenderAt(plan *renderplan.Plan, props any, now time.Time) (string, error)

RenderAt is like Render but uses an explicit render clock. A zero now uses the renderer's clock function (default time.Now).

Types

type Error

type Error struct {
	Code    ErrorCode
	Path    string
	Message string
	Cause   error
}

Error identifies a stable rendering failure and its rendering-plan path.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorCode

type ErrorCode string
const (
	CodeEvaluation ErrorCode = "evaluation_error"
	CodeRender     ErrorCode = "render_error"
	CodeUnsafeURL  ErrorCode = "unsafe_url"
	CodeUnsafeHTML ErrorCode = "unsafe_html"
)
type NavigationMeta struct {
	RouteID  string
	Pathname string
	Params   map[string]string
}

NavigationMeta is request-time route identity injected for portable nav hooks.

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

func New

func New() *Renderer

func (*Renderer) Render

func (r *Renderer) Render(plan *renderplan.Plan, props any) (string, error)

func (*Renderer) RenderAt

func (r *Renderer) RenderAt(plan *renderplan.Plan, props any, now time.Time) (string, time.Time, error)

RenderAt validates and renders a plan using now as the render-snapshot clock. It returns the HTML and the normalized UTC instant that callers must embed in hydration JSON as renderNow. A zero now uses r.now (or time.Now).

func (*Renderer) WithNavigation

func (r *Renderer) WithNavigation(meta NavigationMeta) *Renderer

WithNavigation returns a renderer that seeds `__gobeyond` locals for plan evaluation. Hydration payloads should continue to use the original page props; the browser reads soft-navigation state instead of this namespace.

type SafeHTML

type SafeHTML = renderplan.SafeHTML

SafeHTML and TrustedHTML are renderer-level aliases for applications that do not otherwise need to import the render-plan model.

func TrustedHTML

func TrustedHTML(value string) SafeHTML

Jump to

Keyboard shortcuts

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