display

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package display provides template resolution for converting raw payloads into human-readable display data using a simple template schema.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resolve

func Resolve(tmpl json.RawMessage, payload json.RawMessage) (json.RawMessage, error)

Resolve applies a display template to a payload and returns the resolved output. If the template is nil or empty, it returns nil.

func ValidateTemplate

func ValidateTemplate(raw json.RawMessage) error

ValidateTemplate checks that a display template has a valid structure. It should be called at policy create/update time to reject malformed templates early.

Types

type Resolved

type Resolved struct {
	Title  string          `json:"title,omitempty"`
	Fields []ResolvedField `json:"fields"`
	Items  []ResolvedItem  `json:"items,omitempty"`
}

Resolved is the output stored in metadata.display after template resolution.

type ResolvedField

type ResolvedField struct {
	Label string `json:"label"`
	Value string `json:"value"`
}

ResolvedField is a label-value pair.

type ResolvedItem

type ResolvedItem struct {
	Title  string          `json:"title"`
	Fields []ResolvedField `json:"fields"`
}

ResolvedItem is a titled group of label-value pairs (for batch requests).

type Template

type Template struct {
	Title  string          `json:"title,omitempty"`
	Fields []TemplateField `json:"fields"`
	Items  *TemplateItems  `json:"items,omitempty"`
}

Template defines a display template stored on a policy. It maps payload fields to human-readable labels with optional formatting.

type TemplateField

type TemplateField struct {
	Label  string `json:"label"`
	Path   string `json:"path"`
	Format string `json:"format,omitempty"`
}

TemplateField maps a label to a dot-notation path into the payload.

type TemplateItems

type TemplateItems struct {
	Path      string          `json:"path"`
	LabelPath string          `json:"label_path"`
	Fields    []TemplateField `json:"fields"`
}

TemplateItems defines how to render a list of items from an array in the payload.

Jump to

Keyboard shortcuts

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