https://github.com/emilebosch/tag
Simple HTML tag building for Mono and .NET runtime
https://github.com/emilebosch/tag
c-sharp mono
Last synced: 3 days ago
JSON representation
Simple HTML tag building for Mono and .NET runtime
- Host: GitHub
- URL: https://github.com/emilebosch/tag
- Owner: emilebosch
- Created: 2012-06-25T11:36:20.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2012-06-25T13:17:25.000Z (almost 13 years ago)
- Last Synced: 2025-06-13T06:07:54.124Z (3 days ago)
- Topics: c-sharp, mono
- Language: C#
- Size: 105 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
tag
===Simple HTML tag building for Mono and .NET runtime.
````csharp
//- creating an simple A link, with id and classvar sample1 = new Tag("a","Click for oblivion!", href:"http://somewhere/far/away", id:"starlink", @class:"starred");
Console.WriteLine (sample1);//- the same thing but now via shorthand - the . denotes an class and the # a id
var sample2 = new Tag("a.starlink#starred","Click for oblivion!", href:"http://somewhere/far/away");
Console.WriteLine (sample2);//- creating an UL with child LI
var sample3 = new Tag("ul",
new Tag("li", "Look im an li!", @class:"hello", id:"hello"),
new Tag("li", "Look im another li!", @class:"awesome"));Console.WriteLine (sample3);
//- creating two sibling breaks
var sample4 = new Tag("br");
sample4 += new Tag("br");Console.WriteLine (sample4);
// doing the same thing but lazy via string implicit string conversion
Tag sample5 = "br";
sample5 += "br";
sample5 += (Tag)"hr.rainbow"+(Tag)"hr.doublerainbow";//- or
var sample6 = (Tag)"hr.pretty#main";
Console.WriteLine (sample6);//- some more samples
var stimulants = new []{ "Coffee","Crack", "Energy drink"};
var
html =
new Tag("ul.CLASS#ID",
new Tag("li.CLASS#ID", content: "CONTENT", name: "MYNAME", type: "MYTYPE"),
new Tag("li.CLASS#ID", "CONTENT", name: "MYNAME"));html +=
new Tag("div.CLASS#ID",content: "CONTENT", id: "myid", name:"NAME", href:"HREF",
target:"TARGET", title:"TITLE", style:"asd", alt:"ALT", src:"SRC");html += "hr.CLASS";
html += new Tag("ul#toplist",
from
stimulant
in
stimulants
select
new Tag("li",stimulant, @class:(stimulant=="Crack"?"illegal":"ok")));Console.WriteLine (html.ToString());
````