-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtagbuilder_test.go
58 lines (48 loc) · 1.25 KB
/
tagbuilder_test.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package html5tag
import "fmt"
func ExampleTagBuilder_Tag() {
fmt.Println(NewTagBuilder().Tag("div"))
// Output: <div></div>
}
func ExampleTagBuilder_Set() {
fmt.Println(NewTagBuilder().Tag("div").Set("me", "you"))
// Output: <div me="you"></div>
}
func ExampleTagBuilder_ID() {
fmt.Println(NewTagBuilder().Tag("div").ID("bob"))
// Output: <div id="bob"></div>
}
func ExampleTagBuilder_Class() {
fmt.Println(NewTagBuilder().Tag("div").Class("bob sam"))
// Output: <div class="bob sam"></div>
}
func ExampleTagBuilder_Link() {
fmt.Println(NewTagBuilder().Link("http://example.com"))
// Output: <a href="http://example.com"></a>
}
func ExampleTagBuilder_IsVoid() {
fmt.Println(NewTagBuilder().Tag("img").IsVoid())
// Output: <img>
}
func ExampleTagBuilder_InnerHtml() {
fmt.Println(NewTagBuilder().Tag("div").InnerHtml("<p>A big deal</p>"))
// Output:
// <div>
// <p>A big deal</p>
// </div>
}
func ExampleTagBuilder_InnerText() {
fmt.Println(NewTagBuilder().Tag("div").InnerText("<p>A big deal</p>"))
// Output:
// <div>
// <p>A big deal</p>
// </div>
}
func ExampleTagBuilder_String() {
s := NewTagBuilder().Tag("div").InnerHtml("<p>A big deal</p>").String()
fmt.Println(s)
// Output:
// <div>
// <p>A big deal</p>
// </div>
}