Skip to content

Commit 122f818

Browse files
committed
updated readme
1 parent 71f5ef8 commit 122f818

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

CSHtml.Examples/ModularHtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private static HtmlBuilder header()
6464
return head;
6565
}
6666

67-
public static HtmlBuilder footer()
67+
private static HtmlBuilder footer()
6868
{
6969
HtmlBuilder foot = new HtmlBuilder();
7070

CSHtml.Examples/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ internal class Program
66
{
77
static void Main(string[] args)
88
{
9-
BasicExamples.WriteSimpleHtml();
9+
ModularHtml.WritePages();
1010

1111
Console.ReadLine();
1212
}

README.md

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,82 @@ using (builder.AddTag(HtmlTag.Html))
3535
}
3636
}
3737
}
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+
HtmlBuilder page1 = new HtmlBuilder();
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+
private static HtmlBuilder header()
88+
{
89+
HtmlBuilder head = new HtmlBuilder();
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+
return head;
100+
}
101+
102+
private static HtmlBuilder footer()
103+
{
104+
HtmlBuilder foot = new HtmlBuilder();
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");
111+
}
112+
}
113+
114+
return foot;
115+
}
116+
```

0 commit comments

Comments
 (0)