scope.go 575 B

1234567891011121314151617181920212223242526272829303132
  1. package web
  2. import (
  3. "context"
  4. h "github.com/theplant/htmlgo"
  5. )
  6. type ScopeBuilder struct {
  7. tag *h.HTMLTagBuilder
  8. }
  9. func Scope(children ...h.HTMLComponent) (r *ScopeBuilder) {
  10. r = &ScopeBuilder{
  11. tag: h.Tag("go-plaid-scope").Children(children...),
  12. }
  13. return
  14. }
  15. func (b *ScopeBuilder) VSlot(v string) (r *ScopeBuilder) {
  16. b.tag.Attr("v-slot", v)
  17. return b
  18. }
  19. func (b *ScopeBuilder) Init(v string) (r *ScopeBuilder) {
  20. b.tag.Attr(":init", v)
  21. return b
  22. }
  23. func (b *ScopeBuilder) MarshalHTML(ctx context.Context) (r []byte, err error) {
  24. return b.tag.MarshalHTML(ctx)
  25. }