views

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package views generates server-rendered and Inertia views from resource metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ResourceName    string
	ModelName       string
	EntityName      string
	PluralName      string
	ModelPluralName string
	TableName       string
	ModelTableName  string
	Namespace       string
	ModulePath      string
	Actions         []string
}

Config controls view generation for a resource.

type GeneratedView

type GeneratedView struct {
	ResourceName     string
	ModelName        string
	EntityName       string
	PluralName       string
	ModelPluralName  string
	Namespace        string
	NamespacePascal  string
	Fields           []ViewField
	ModulePath       string
	IDType           string // "uuid.UUID", "int32", "int64", "string"
	IDFieldName      string
	Actions          []string
	AvailableActions []string
}

GeneratedView contains the template data for generated resource views.

type Generator

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

Generator builds view template data and writes view files.

func NewGenerator

func NewGenerator(databaseType string) *Generator

NewGenerator creates a new generator.

func (*Generator) Build

func (g *Generator) Build(cat *catalog.Catalog, config Config) (*GeneratedView, error)

Build converts catalog metadata and config into generated view data.

func (*Generator) GenerateInertiaViewFiles added in v1.0.0

func (g *Generator) GenerateInertiaViewFiles(view *GeneratedView, templatePrefix, extension string) (map[string]string, error)

GenerateInertiaViewFiles renders Inertia page components for a resource.

func (*Generator) GenerateView

func (g *Generator) GenerateView(
	cat *catalog.Catalog,
	resourceName string,
	tableName string,
	modulePath string,
	namespace string,
) error

GenerateView renders server-rendered views for a resource.

func (*Generator) GenerateViewFile

func (g *Generator) GenerateViewFile(view *GeneratedView, withController bool, templatePrefix string) (string, error)

GenerateViewFile renders a server-rendered view template.

func (*Generator) GenerateViewWithController

func (g *Generator) GenerateViewWithController(
	cat *catalog.Catalog,
	resourceName string,
	tableName string,
	modulePath string,
	withController bool,
	inertia string,
	namespace string,
) error

GenerateViewWithController renders views and optionally supports controller wiring.

func (*Generator) GenerateViewWithControllerActions added in v1.0.0

func (g *Generator) GenerateViewWithControllerActions(
	cat *catalog.Catalog,
	resourceName string,
	tableName string,
	modulePath string,
	withController bool,
	actions []string,
	inertia string,
	namespace string,
) error

GenerateViewWithControllerActions renders views for a selected action set.

func (*Generator) GenerateViewWithControllerActionsForModel added in v1.0.0

func (g *Generator) GenerateViewWithControllerActionsForModel(
	cat *catalog.Catalog,
	resourceName string,
	modelName string,
	tableName string,
	modelTableName string,
	modulePath string,
	namespace string,
	withController bool,
	actions []string,
	inertia string,
) error

GenerateViewWithControllerActionsForModel renders action views for a distinct model name.

type InertiaPageData added in v1.0.0

type InertiaPageData struct {
	*GeneratedView
	ComponentName string
}

InertiaPageData wraps generated view data with an Inertia component name.

type ViewField

type ViewField struct {
	Name            string
	GoType          string
	GoFormType      string
	DisplayName     string
	IsTimestamp     bool
	InputType       string
	StringConverter string
	DBName          string
	CamelCase       string
	IsSystemField   bool
}

ViewField describes one form or display field in generated views.

Jump to

Keyboard shortcuts

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