-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathequivnode.go
37 lines (31 loc) · 1.07 KB
/
equivnode.go
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
package smetana
import "fmt"
// A "meta" [Node] in an HTML document to associate some "content" value to a
// particular "http-equiv" (see [MetaNode] for a more generic node using "name"
// instead of "http-equiv").
type EquivNode struct {
Equiv string
Content string
}
// Convert an [EquivNode] to HTML
func (node EquivNode) ToHtml(builder *Builder) {
// `meta` is a void tag so we only need the opening tag
builder.writeOpeningTag("meta", Attrs{
"http-equiv": node.Equiv,
"content": node.Content,
})
}
// Create a generic [EquivNode] with the given http-equiv and content
func Equiv(equiv string, content string) EquivNode {
return EquivNode{equiv, content}
}
// Create an [EquivNode] with "http-equiv" set to "refresh" and "content"
// set to the provided value in seconds.
func Refresh(value uint) EquivNode {
return EquivNode{"refresh", fmt.Sprintf("%d", value)}
}
// Create an [EquivNode] with "http-equiv" set to "x-ua-compatible" and
// "content" set to the given value
func XUaCompatible(value string) EquivNode {
return EquivNode{"x-ua-compatible", value}
}