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 ¶
- func GenerateAssetPath(manager web.AssetManagerInterface) func(string) string
- func GetCSRFToken(c echo.Context) string
- func GetCurrentUser(c echo.Context) *entities.User
- func GetMessageClass(msgType string) string
- func GetMessageIcon(msgType string) string
- func GetSession(c echo.Context) *session.Session
- type Message
- type PageData
- func (p *PageData) GetUser() *entities.User
- func (p *PageData) GetUserEmail() string
- func (p *PageData) GetUserID() string
- func (p *PageData) HasMessage() bool
- func (p *PageData) IsAuthenticated() bool
- func (p *PageData) SetUser(user *entities.User)
- func (p *PageData) WithAuthor(author string) *PageData
- func (p *PageData) WithContent(content templ.Component) *PageData
- func (p *PageData) WithDescription(description string) *PageData
- func (p *PageData) WithForm(form *model.Form) *PageData
- func (p *PageData) WithFormBuilderAssetPath(path string) *PageData
- func (p *PageData) WithFormPreviewAssetPath(path string) *PageData
- func (p *PageData) WithForms(forms []*model.Form) *PageData
- func (p *PageData) WithKeywords(keywords string) *PageData
- func (p *PageData) WithMessage(msgType, text string) *PageData
- func (p *PageData) WithSubmissions(submissions []*model.FormSubmission) *PageData
- func (p *PageData) WithTitle(title string) *PageData
- type Renderer
- type ViteManifest
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
GetCSRFToken retrieves the CSRF token from context
func GetCurrentUser ¶ added in v0.1.5
GetCurrentUser extracts user data from context
func GetMessageClass ¶ added in v0.1.5
GetMessageClass returns the appropriate Bootstrap CSS class for a message type
func GetMessageIcon ¶ added in v0.1.5
GetMessageIcon returns the appropriate Bootstrap icon name for a message type
Types ¶
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) GetUserEmail ¶ added in v0.1.5
GetUserEmail returns the current user email or empty string if not authenticated
func (*PageData) GetUserID ¶ added in v0.1.5
GetUserID returns the current user ID or empty string if not authenticated
func (*PageData) HasMessage ¶ added in v0.1.5
HasMessage checks if there's a message to display
func (*PageData) IsAuthenticated ¶ added in v0.1.5
IsAuthenticated checks if the user is authenticated
func (*PageData) WithAuthor ¶ added in v0.1.5
WithAuthor sets the page author
func (*PageData) WithContent ¶ added in v0.1.5
WithContent sets the page content component
func (*PageData) WithDescription ¶ added in v0.1.5
WithDescription sets the page description
func (*PageData) WithFormBuilderAssetPath ¶ added in v0.1.5
WithFormBuilderAssetPath sets the form builder asset path
func (*PageData) WithFormPreviewAssetPath ¶ added in v0.1.5
WithFormPreviewAssetPath sets the form preview asset path
func (*PageData) WithKeywords ¶ added in v0.1.5
WithKeywords sets the page keywords
func (*PageData) WithMessage ¶ added in v0.1.5
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
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 ¶
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