Documentation
¶
Index ¶
- Constants
- Variables
- func Actionable[T h.HTMLComponent](ctx context.Context, c T, children ...h.HTMLComponent) (r h.HTMLComponent)
- func AppendReloadToResponse(r *web.EventResponse, c Identifiable)
- func Clone[T any](src T) (T, error)
- func Copy(dst, src any) error
- func GetFuncName(f any) string
- func IdentifiableCookieKey(v Identifiable) string
- func Install(b web.EventFuncHub, dc *DependencyCenter)
- func IsQuerySubset(sup, sub url.Values) bool
- func IsRawQuerySubset(sup, sub string) bool
- func IsSyncQuery(ctx context.Context) bool
- func MurmurHash3(input string) string
- func MustClone[T any](src T) T
- func OnReload(c Identifiable) (r web.EventResponse, err error)
- func ParseQuery(c h.HTMLComponent) h.HTMLComponent
- func PostAction(ctx context.Context, c any, method any, request any, opts ...PostActionOption) *web.VueEventTagBuilder
- func PrettyJSONString(v any) (r string)
- func RegisterActionableCompoType(vs ...h.HTMLComponent)
- func ReloadAction[T Identifiable](ctx context.Context, source T, f func(target T), opts ...PostActionOption) *web.VueEventTagBuilder
- func SkipPortalize(c Identifiable) h.HTMLComponent
- func SyncQuery(c h.HTMLComponent) h.HTMLComponent
- func Unwrap(c h.HTMLComponent) h.HTMLComponent
- func WithPortalName(ctx context.Context, name string) context.Context
- type Action
- type DependencyCenter
- func (dc *DependencyCenter) Apply(ctx context.Context, target h.HTMLComponent) error
- func (dc *DependencyCenter) Inject(injectorName string, c h.HTMLComponent) (h.HTMLComponent, error)
- func (dc *DependencyCenter) Injector(name string) (*inject.Injector, error)
- func (dc *DependencyCenter) MustApply(ctx context.Context, target h.HTMLComponent) h.HTMLComponent
- func (dc *DependencyCenter) MustInject(injectorName string, c h.HTMLComponent) h.HTMLComponent
- func (dc *DependencyCenter) MustProvide(name string, fs ...any)
- func (dc *DependencyCenter) Provide(name string, fs ...any) error
- func (dc *DependencyCenter) RegisterInjector(name string, opts ...RegisterInjectorOption)
- type Identifiable
- type InjectorName
- type PostActionOption
- type QueryTag
- type QueryTagMethod
- type QueryTags
- type RegisterInjectorOption
- type Unwrapable
Constants ¶
View Source
const ( LocalsKeyNewAction = "newAction" LocalsKeyQueryTags = "queryTags" LocalsKeySetCookies = "setCookies" LocalsKeyEncodeQuery = "encodeQuery" )
Variables ¶
View Source
var ErrInjectorNotFound = errors.New("injector not found")
View Source
var QueryTagMethodBare = &QueryTagMethod{ Name: "bare", Encoder: `({ value, queries, tag }) => { if (value) { value.split('&').forEach((query) => { queries.push(query) }) } }`, Decoder: func(qs url.Values, tag QueryTag, v any) error { if len(tag.Args) < 1 { return fmt.Errorf("bare query tag method requires at least one argument") } bareQuery := make(url.Values) prefix := tag.Args[0] for k, vs := range qs { if strings.HasPrefix(k, prefix) { for _, v := range vs { unescaped, err := url.QueryUnescape(v) if err != nil { return fmt.Errorf("failed to unescape %q: %w", v, err) } bareQuery.Add(k, unescaped) } } } reflectutils.Set(v, tag.path, bareQuery.Encode()) return nil }, }
tag example: `query:";method=bare,f_"` arg0: the prefix of the query key
View Source
var QueryTagMethods = []*QueryTagMethod{ QueryTagMethodBare, }
View Source
var QueryTagMethodsMap = func() map[string]*QueryTagMethod { m := map[string]*QueryTagMethod{} for _, v := range QueryTagMethods { if _, ok := m[v.Name]; ok { panic(fmt.Sprintf("duplicate query tag method %q", v.Name)) } m[v.Name] = v } return m }()
Functions ¶
func Actionable ¶
func Actionable[T h.HTMLComponent](ctx context.Context, c T, children ...h.HTMLComponent) (r h.HTMLComponent)
func AppendReloadToResponse ¶
func AppendReloadToResponse(r *web.EventResponse, c Identifiable)
func GetFuncName ¶
func IdentifiableCookieKey ¶
func IdentifiableCookieKey(v Identifiable) string
func Install ¶
func Install(b web.EventFuncHub, dc *DependencyCenter)
func IsQuerySubset ¶
IsQuerySubset checks if all key-value pairs in sub are contained within sup, considering comma-separated.
func IsRawQuerySubset ¶
IsRawQuerySubset checks if all key-value pairs in the sub query string are contained within the sup query string.
func IsSyncQuery ¶
func MurmurHash3 ¶
func OnReload ¶
func OnReload(c Identifiable) (r web.EventResponse, err error)
func ParseQuery ¶
func ParseQuery(c h.HTMLComponent) h.HTMLComponent
func PostAction ¶
func PostAction(ctx context.Context, c any, method any, request any, opts ...PostActionOption) *web.VueEventTagBuilder
func PrettyJSONString ¶
func RegisterActionableCompoType ¶
func RegisterActionableCompoType(vs ...h.HTMLComponent)
func ReloadAction ¶
func ReloadAction[T Identifiable](ctx context.Context, source T, f func(target T), opts ...PostActionOption) *web.VueEventTagBuilder
func SkipPortalize ¶
func SkipPortalize(c Identifiable) h.HTMLComponent
func SyncQuery ¶
func SyncQuery(c h.HTMLComponent) h.HTMLComponent
func Unwrap ¶
func Unwrap(c h.HTMLComponent) h.HTMLComponent
Types ¶
type Action ¶
type Action struct {
CompoType string `json:"compo_type"`
Compo json.RawMessage `json:"compo"`
Injector string `json:"injector"`
SyncQuery bool `json:"sync_query"`
Method string `json:"method"`
Request json.RawMessage `json:"request"`
}
type DependencyCenter ¶
type DependencyCenter struct {
// contains filtered or unexported fields
}
func NewDependencyCenter ¶
func NewDependencyCenter() *DependencyCenter
func (*DependencyCenter) Apply ¶
func (dc *DependencyCenter) Apply(ctx context.Context, target h.HTMLComponent) error
func (*DependencyCenter) Inject ¶
func (dc *DependencyCenter) Inject(injectorName string, c h.HTMLComponent) (h.HTMLComponent, error)
func (*DependencyCenter) Injector ¶
func (dc *DependencyCenter) Injector(name string) (*inject.Injector, error)
func (*DependencyCenter) MustApply ¶
func (dc *DependencyCenter) MustApply(ctx context.Context, target h.HTMLComponent) h.HTMLComponent
func (*DependencyCenter) MustInject ¶
func (dc *DependencyCenter) MustInject(injectorName string, c h.HTMLComponent) h.HTMLComponent
func (*DependencyCenter) MustProvide ¶
func (dc *DependencyCenter) MustProvide(name string, fs ...any)
func (*DependencyCenter) Provide ¶
func (dc *DependencyCenter) Provide(name string, fs ...any) error
func (*DependencyCenter) RegisterInjector ¶
func (dc *DependencyCenter) RegisterInjector(name string, opts ...RegisterInjectorOption)
type Identifiable ¶
type Identifiable interface {
h.HTMLComponent
CompoID() string
}
type InjectorName ¶
type InjectorName string
just to make it easier to get the name of the currently applied injector
type PostActionOption ¶
type PostActionOption func(*postActionOptions)
func WithAppendFix ¶
func WithAppendFix(v string) PostActionOption
func WithUseProvidedCompo ¶
func WithUseProvidedCompo() PostActionOption
type QueryTagMethod ¶
type RegisterInjectorOption ¶
type RegisterInjectorOption func(*registerInjectorOptions)
func WithParent ¶
func WithParent(parent string) RegisterInjectorOption
type Unwrapable ¶
type Unwrapable interface {
Unwrap() h.HTMLComponent
}
Click to show internal directories.
Click to hide internal directories.