Documentation
¶
Overview ¶
Package flash provides experimental request-scoped flash message helpers.
Index ¶
- func Add(ctx context.Context, messages ...Message) context.Context
- func Flash(ctx ...*partial.RenderContext) template.HTML
- func FlashTarget(ctx ...*partial.RenderContext) template.HTML
- func FuncMap() template.FuncMap
- func Has(ctx context.Context) bool
- func HasFlashes(ctx ...*partial.RenderContext) bool
- func Stage(opts ...Option) partial.RenderStage
- func WithStore(ctx context.Context, store *Store) context.Context
- type Data
- type Level
- type Message
- func Drain(ctx context.Context) []Message
- func Error(text string) Message
- func Flashes(ctx ...*partial.RenderContext) []Message
- func Info(text string) Message
- func Messages(ctx context.Context) []Message
- func New(level Level, text string) Message
- func Success(text string) Message
- func Warn(text string) Message
- type Option
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Flash ¶
func Flash(ctx ...*partial.RenderContext) template.HTML
Flash renders flash messages for a render context with the default template.
go-doc:sig func() html/template.HTML
func FlashTarget ¶
func FlashTarget(ctx ...*partial.RenderContext) template.HTML
FlashTarget renders the default flash target container.
go-doc:sig func() html/template.HTML
func HasFlashes ¶
func HasFlashes(ctx ...*partial.RenderContext) bool
HasFlashes reports whether a render context has request-scoped flash messages.
go-doc:sig func() bool
Types ¶
type Message ¶
Message is one request-scoped flash message.
func Flashes ¶
func Flashes(ctx ...*partial.RenderContext) []Message
Flashes returns request-scoped flash messages for a render context.
go-doc:sig func() []github.com/donseba/go-partial/exp/flash.Message
type Option ¶
type Option func(*options)
Option configures the flash renderer.
func WithPartial ¶
WithPartial renders flash messages with a user-provided partial.
func WithTargetID ¶
WithTargetID changes the DOM ID used by the default flash target and the data passed to flash templates.
func WithTargetPartial ¶
WithTargetPartial renders flashTarget with a user-provided partial.
func WithTargetTemplate ¶
WithTargetTemplate renders flashTarget with a user template from the active partial tree filesystem.
func WithTemplate ¶
WithTemplate renders flash messages with a user template from the active partial tree filesystem.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds flash messages for one request or app-owned session handoff.
Store is safe for concurrent Add, Messages, and Drain calls, but most applications should still treat a store as request/session-owned state.
func FromContext ¶
FromContext returns the flash store from ctx, if present.