Skip to content

Commit 9133555

Browse files
committed
readme
1 parent 57ffe1b commit 9133555

File tree

6 files changed

+131
-2
lines changed

6 files changed

+131
-2
lines changed

CSHtml.Examples/BasicExample.cs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CSHtml.Examples
8+
{
9+
public class BasicExamples
10+
{
11+
public static void WriteSimpleHtml()
12+
{
13+
HtmlBuilder builder = new HtmlBuilder();
14+
15+
using (builder.AddTag(HtmlTag.Html))
16+
{
17+
using (builder.AddTag(HtmlTag.Body, (HtmlAttribute.Class, "main_body")))
18+
{
19+
using (builder.AddTag(HtmlTag.H1))
20+
{
21+
builder.WriteLine("Heading");
22+
}
23+
24+
using (builder.AddTag(HtmlTag.P))
25+
{
26+
builder.WriteLine("This is a paragraph");
27+
}
28+
}
29+
}
30+
31+
Console.Write(builder.ToString());
32+
}
33+
34+
public static void MultipleTags()
35+
{
36+
HtmlBuilder builder = new HtmlBuilder();
37+
38+
using (builder.AddTag(HtmlTag.Html))
39+
{
40+
using (builder.AddTag(HtmlTag.Body, (HtmlAttribute.Class, "main_body")))
41+
{
42+
using (builder.AddTag(HtmlTag.H2))
43+
{
44+
builder.WriteLine("Span with multiple tags");
45+
}
46+
47+
using (builder.AddTag(HtmlTag.P))
48+
{
49+
builder.WriteLine("Define a span with the source, width and height");
50+
}
51+
52+
using (builder.AddTag(HtmlTag.Span, (HtmlAttribute.Src, "my_icon.jpg"), (HtmlAttribute.Width, "100"), (HtmlAttribute.Height, "150")))
53+
{
54+
}
55+
}
56+
}
57+
58+
Console.Write(builder.ToString());
59+
}
60+
}
61+
}

CSHtml.Examples/ModularHtml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CSHtml.Examples
8+
{
9+
public class ModularHtml
10+
{
11+
}
12+
}

CSHtml.Examples/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ internal class Program
66
{
77
static void Main(string[] args)
88
{
9-
Console.WriteLine("Hello World!");
9+
BasicExamples.WriteSimpleHtml();
10+
11+
Console.ReadLine();
1012
}
1113
}
1214
}

CSHtml.Examples/SaveDocument.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CSHtml.Examples
8+
{
9+
public class SaveDocument
10+
{
11+
}
12+
}

CSHtml.sln

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSHtml", "CSHtml\CSHtml.csp
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSHtml.Examples", "CSHtml.Examples\CSHtml.Examples.csproj", "{C988E54A-1430-40B4-938B-6AF680E74DE3}"
99
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C4670E9B-7DF7-459B-8CFA-00B183847A85}"
11+
ProjectSection(SolutionItems) = preProject
12+
README.md = README.md
13+
EndProjectSection
14+
EndProject
1015
Global
1116
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1217
Debug|Any CPU = Debug|Any CPU

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,38 @@
1-
# CSHtml
1+
# CSHtml
2+
3+
Library to write HTML documents using .NET
4+
5+
## Syntax Example
6+
7+
Example of basic html
8+
9+
```html
10+
<html>
11+
<body class="main_body">
12+
<h1>Heading</h1>
13+
<p>This is a paragraph</p>
14+
</body>
15+
</html>
16+
```
17+
18+
CSHtml syntact to write the html sample:
19+
20+
```c#
21+
HtmlBuilder builder = new HtmlBuilder();
22+
23+
using (builder.AddTag(HtmlTag.Html))
24+
{
25+
using (builder.AddTag(HtmlTag.Body, (HtmlAttribute.Class, "main_body")))
26+
{
27+
using (builder.AddTag(HtmlTag.H1))
28+
{
29+
builder.WriteLine("Heading");
30+
}
31+
32+
using (builder.AddTag(HtmlTag.P))
33+
{
34+
builder.WriteLine("This is a paragraph");
35+
}
36+
}
37+
}
38+
```

0 commit comments

Comments
 (0)