You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+79-1Lines changed: 79 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,4 +35,82 @@ using (builder.AddTag(HtmlTag.Html))
35
35
}
36
36
}
37
37
}
38
-
```
38
+
```
39
+
40
+
Write once use it everywhere, you can have an html splited in different ```HtmlBuilders``` and merge them in the different documents, for example you can setup a default header and footer and use the same bulider for all your pages:
41
+
42
+
```html
43
+
<html>
44
+
45
+
<!-- Head to use in all the pages -->
46
+
<head>
47
+
<title>
48
+
This is the default title for all pages
49
+
</title>
50
+
</head>
51
+
52
+
<!-- Dynamic body that changes between pages -->
53
+
<body>
54
+
Dynamic main content in this html page
55
+
</body>
56
+
57
+
<!-- Footer to use in all the pages -->
58
+
<footer>
59
+
<p>
60
+
Author: this is the author of the pages
61
+
</p>
62
+
</footer>
63
+
</html>
64
+
```
65
+
66
+
C# example for how to create the static elements in the html:
67
+
68
+
```c#
69
+
HtmlBuilderpage1=newHtmlBuilder();
70
+
71
+
using (page1.AddTag(HtmlTag.Html))
72
+
{
73
+
page1.AddChunk(header());
74
+
75
+
using (page1.AddTag(HtmlTag.Body))
76
+
{
77
+
page1.WriteLine("Dynamic main content in this html page 001");
78
+
}
79
+
80
+
page1.AddChunk(footer());
81
+
}
82
+
```
83
+
84
+
Where ```header()``` and ```footer()``` implementation looks like:
85
+
86
+
```c#
87
+
privatestaticHtmlBuilderheader()
88
+
{
89
+
HtmlBuilderhead=newHtmlBuilder();
90
+
91
+
using (head.AddTag(HtmlTag.Head))
92
+
{
93
+
using (head.AddTag(HtmlTag.Title))
94
+
{
95
+
head.WriteLine("This is the default title for all pages");
96
+
}
97
+
}
98
+
99
+
returnhead;
100
+
}
101
+
102
+
privatestaticHtmlBuilderfooter()
103
+
{
104
+
HtmlBuilderfoot=newHtmlBuilder();
105
+
106
+
using (foot.AddTag(HtmlTag.Footer))
107
+
{
108
+
using (foot.AddTag(HtmlTag.P))
109
+
{
110
+
foot.WriteLine("Author: this is the author of the pages");
0 commit comments