-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstd_component.go
More file actions
54 lines (43 loc) · 1.09 KB
/
std_component.go
File metadata and controls
54 lines (43 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2026 Brent Rowland.
// Use of this source code is governed by the Apache License, Version 2.0, as described in the LICENSE file.
package ltml
import "sync/atomic"
type StdComponent struct {
StdContainer
body string
source textSource
}
var networkAssetsDisabled atomic.Bool
func DisableNetworkAssets() {
networkAssetsDisabled.Store(true)
}
func (c *StdComponent) Body() string {
body, err := c.source.Text(c.doc, c.container, c.body, "component")
if err != nil {
return ""
}
return body
}
func (c *StdComponent) SetBody(body string) {
if c.source.Explicit() {
return
}
c.body = body
}
func (c *StdComponent) SetAttrs(attrs map[string]string) {
c.StdContainer.SetAttrs(attrs)
c.source.SetAttrs(attrs)
}
func (c *StdComponent) ensureBody() error {
if !c.source.Explicit() {
return nil
}
_, err := c.assetSource()
return err
}
func (c *StdComponent) assetSource() (assetSourceRef, error) {
return c.source.assetSource(c.doc, c.container, "component")
}
var _ Component = (*StdComponent)(nil)
var _ HasAttrs = (*StdComponent)(nil)
var _ WantsDoc = (*StdComponent)(nil)