view

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Always

func Always(value interface{}) gonertia.AlwaysProp

Always creates a prop that always loads (even on partial reloads)

func Back

func Back(w http.ResponseWriter, r *http.Request)

Back redirects back (SPA navigation)

func Defer

func Defer(value interface{}, group ...string) gonertia.DeferProp

Defer creates a deferred prop that loads after the initial response

func Error

func Error(w http.ResponseWriter, r *http.Request, message string, url string)

Error redirects with an error message

func FormError

func FormError(w http.ResponseWriter, r *http.Request, errors map[string]interface{})

FormError redirects back with form validation errors

func Inertia

func Inertia() *gonertia.Inertia

Inertia returns the gonertia instance

func Initialize

func Initialize(config Config) error

Initialize sets up the view manager with gonertia

func LazyProp

func LazyProp(value interface{}) gonertia.OptionalProp

LazyProp creates a lazy prop that only evaluates when needed Note: In gonertia, LazyProp is an alias for OptionalProp

func LoadTemplateFromFile

func LoadTemplateFromFile(path string) (string, error)

LoadTemplateFromFile loads the root template from a file

func Location

func Location(w http.ResponseWriter, r *http.Request, url string)

Location performs an external redirect (forces full page load) Use this only for external URLs or when you need to break out of the SPA

func Middleware

func Middleware() router.MiddlewareFunc

Middleware returns gonertia middleware for use with routers

func Optional

func Optional(value interface{}) gonertia.OptionalProp

Optional creates an optional prop that only loads on direct visits

func Redirect

func Redirect(w http.ResponseWriter, r *http.Request, url string)

Redirect performs a plain Inertia redirect (for internal navigation) This is the correct method for SPA navigation within your app Uses 303 See Other for POST-Redirect-GET pattern

func Render

func Render(w http.ResponseWriter, r *http.Request, component string, props Props) error

Render renders a component with props It automatically merges props from context (set by middleware) with the provided props

func SetProp

func SetProp(ctx context.Context, key string, value interface{}) context.Context

SetProp sets a single prop in the request context

func SetProps

func SetProps(ctx context.Context, props Props) context.Context

SetProps sets props in the request context for sharing across the request

func SetSharePropsFunc

func SetSharePropsFunc(fn SharePropsFunc)

SetSharePropsFunc sets a function that will be called to get shared props for each request

func SetTemplateData

func SetTemplateData(data gonertia.TemplateData)

SetTemplateData sets template data for the root template

func Share

func Share(key string, value interface{})

Share shares props globally

func ShareFunc

func ShareFunc(key string, fn func(r *http.Request) (interface{}, error))

ShareFunc shares a function prop

func ShareMultiple

func ShareMultiple(props gonertia.Props)

ShareMultiple shares multiple props at once

func ShareTemplateData

func ShareTemplateData(key string, value interface{})

ShareTemplateData shares data to the template

func ShareTemplateFunc

func ShareTemplateFunc(key string, fn interface{}) error

ShareTemplateFunc shares a function to the template

func Success

func Success(w http.ResponseWriter, r *http.Request, message string, url string)

Success redirects with a success message

func WithContext

func WithContext(r *http.Request) *gonertia.Inertia

WithContext returns an Inertia instance from the request context

func WithErrors

func WithErrors(w http.ResponseWriter, r *http.Request, component string, props gonertia.Props, errors map[string]interface{}) error

WithErrors renders with validation errors

func WithFlash

func WithFlash(w http.ResponseWriter, r *http.Request, component string, props gonertia.Props, flash map[string]interface{}) error

WithFlash renders with flash message

Types

type Config

type Config struct {
	RootTemplate string
	Version      string
	SSREnabled   bool
	SSRURL       string
}

Config holds view configuration

type Manager

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

Manager manages view engines

func Get

func Get() *Manager

Get returns the singleton view manager

type Props

type Props = gonertia.Props

Props is a type alias for gonertia.Props

type SharePropsFunc

type SharePropsFunc func(r *http.Request) (Props, error)

SharePropsFunc is a function that returns props to be shared

type SimpleFlashProvider

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

SimpleFlashProvider is a basic flash message provider

func NewSimpleFlashProvider

func NewSimpleFlashProvider() *SimpleFlashProvider

NewSimpleFlashProvider creates a new flash provider

func (*SimpleFlashProvider) GetFlashData

func (p *SimpleFlashProvider) GetFlashData(r *http.Request) (map[string]interface{}, error)

GetFlashData returns all flash messages

func (*SimpleFlashProvider) Set

func (p *SimpleFlashProvider) Set(key string, value interface{})

Set sets a flash message

type SimpleValidationProvider

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

SimpleValidationProvider is a basic validation errors provider

func NewSimpleValidationProvider

func NewSimpleValidationProvider() *SimpleValidationProvider

NewSimpleValidationProvider creates a new validation provider

func (*SimpleValidationProvider) GetOldInput

func (p *SimpleValidationProvider) GetOldInput(r *http.Request) (map[string]interface{}, error)

GetOldInput returns old form input (preserved on validation errors)

func (*SimpleValidationProvider) GetValidationErrors

func (p *SimpleValidationProvider) GetValidationErrors(r *http.Request) (map[string]interface{}, error)

GetValidationErrors returns validation errors

func (*SimpleValidationProvider) Set

func (p *SimpleValidationProvider) Set(errors map[string]interface{})

Set sets validation errors

type VelocityHelpers

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

VelocityHelpers provides Velocity-specific enhancements to gonertia

func Helpers

func Helpers() *VelocityHelpers

Helpers returns a new VelocityHelpers instance

Jump to

Keyboard shortcuts

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