view

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package view provides types and utilities for rendering page data and templates.

Package view provides types and utilities for rendering page data and templates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateAssetPath added in v0.1.5

func GenerateAssetPath(manager web.AssetManagerInterface) func(string) string

GenerateAssetPath creates asset paths using the provided AssetManager

func GetCSRFToken added in v0.1.5

func GetCSRFToken(c echo.Context) string

GetCSRFToken retrieves the CSRF token from context

func GetCurrentUser added in v0.1.5

func GetCurrentUser(c echo.Context) *entities.User

GetCurrentUser extracts user data from context

func GetMessageClass added in v0.1.5

func GetMessageClass(msgType string) string

GetMessageClass returns the appropriate Bootstrap CSS class for a message type

func GetMessageIcon added in v0.1.5

func GetMessageIcon(msgType string) string

GetMessageIcon returns the appropriate Bootstrap icon name for a message type

func GetSession added in v0.1.5

func GetSession(c echo.Context) *session.Session

GetSession retrieves the session from context

Types

type Message added in v0.1.5

type Message struct {
	Type string
	Text string
}

Message represents a user-facing message

type PageData added in v0.1.5

type PageData struct {
	Title                string
	Description          string
	Keywords             string
	Author               string
	Version              string
	BuildTime            string
	GitCommit            string
	Environment          string
	AssetPath            func(string) string
	User                 *entities.User
	Forms                []*model.Form
	Form                 *model.Form
	Submissions          []*model.FormSubmission
	CSRFToken            string
	IsDevelopment        bool
	Content              templ.Component
	FormBuilderAssetPath string
	FormPreviewAssetPath string
	Message              *Message
	Config               *config.Config
	Session              *session.Session
}

PageData represents the data passed to templates

func NewPageData added in v0.1.5

func NewPageData(cfg *config.Config, manager web.AssetManagerInterface, c echo.Context, title string) *PageData

NewPageData creates a new PageData instance with essential data

func (*PageData) GetUser added in v0.1.5

func (p *PageData) GetUser() *entities.User

GetUser returns the current user

func (*PageData) GetUserEmail added in v0.1.5

func (p *PageData) GetUserEmail() string

GetUserEmail returns the current user email or empty string if not authenticated

func (*PageData) GetUserID added in v0.1.5

func (p *PageData) GetUserID() string

GetUserID returns the current user ID or empty string if not authenticated

func (*PageData) HasMessage added in v0.1.5

func (p *PageData) HasMessage() bool

HasMessage checks if there's a message to display

func (*PageData) IsAuthenticated added in v0.1.5

func (p *PageData) IsAuthenticated() bool

IsAuthenticated checks if the user is authenticated

func (*PageData) SetUser added in v0.1.5

func (p *PageData) SetUser(user *entities.User)

SetUser sets the current user

func (*PageData) WithAuthor added in v0.1.5

func (p *PageData) WithAuthor(author string) *PageData

WithAuthor sets the page author

func (*PageData) WithContent added in v0.1.5

func (p *PageData) WithContent(content templ.Component) *PageData

WithContent sets the page content component

func (*PageData) WithDescription added in v0.1.5

func (p *PageData) WithDescription(description string) *PageData

WithDescription sets the page description

func (*PageData) WithForm added in v0.1.5

func (p *PageData) WithForm(form *model.Form) *PageData

WithForm sets a single form

func (*PageData) WithFormBuilderAssetPath added in v0.1.5

func (p *PageData) WithFormBuilderAssetPath(path string) *PageData

WithFormBuilderAssetPath sets the form builder asset path

func (*PageData) WithFormPreviewAssetPath added in v0.1.5

func (p *PageData) WithFormPreviewAssetPath(path string) *PageData

WithFormPreviewAssetPath sets the form preview asset path

func (*PageData) WithForms added in v0.1.5

func (p *PageData) WithForms(forms []*model.Form) *PageData

WithForms sets multiple forms

func (*PageData) WithKeywords added in v0.1.5

func (p *PageData) WithKeywords(keywords string) *PageData

WithKeywords sets the page keywords

func (*PageData) WithMessage added in v0.1.5

func (p *PageData) WithMessage(msgType, text string) *PageData

WithMessage sets a message for the page

func (*PageData) WithSubmissions added in v0.1.5

func (p *PageData) WithSubmissions(submissions []*model.FormSubmission) *PageData

WithSubmissions sets form submissions

func (*PageData) WithTitle added in v0.1.5

func (p *PageData) WithTitle(title string) *PageData

WithTitle sets the page title

type Renderer

type Renderer interface {
	// Render renders a templ component to the response writer
	Render(c echo.Context, t templ.Component) error
}

Renderer defines the interface for rendering views

func NewRenderer

func NewRenderer(logger logging.Logger) Renderer

NewRenderer creates a new view renderer with the given logger

type ViteManifest added in v0.1.5

type ViteManifest struct {
	File    string   `json:"file"`
	Name    string   `json:"name"`
	Src     string   `json:"src,omitempty"`
	CSS     []string `json:"css,omitempty"`
	Assets  []string `json:"assets,omitempty"`
	IsEntry bool     `json:"is_entry"`
}

ViteManifest represents the structure of the Vite manifest file

Jump to

Keyboard shortcuts

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