1 module uim.html.core.html;
2 
3 import std.stdio;
4 import std..string;
5 import std.array;
6 
7 import uim.html;
8 
9 alias STRINGAA = string[string];
10 
11 template sTag(string fName) {
12 	const char[] sTag = "	
13 	 DHTML "~fName~"(STRINGAA values) { return addSTag("~fName~", values); }
14 ";
15 }
16 template dTag(string fName) {
17 	const char[] dTag = "	
18 	 DHTML "~fName~"(T)(T[] content...) { return addDTag("~fName~", contents); }
19 	 DHTML "~fName~"(STRINGAA values) { return addDTag("~fName~", values); }
20 	 DHTML "~fName~"(T)(STRINGAA values, T[] contents...) { return addDTag("~fName~", values, contents); }
21 ";
22 }
23 
24 template STag(string fName, string tName) {
25 	const char[] STag = "	
26  auto "~fName~"() { addS(\""~tName~"\"); return this; }
27  auto "~fName~"(STRINGAA values) { addS(\""~tName~"\", values); return this; }
28 ";
29 }
30 
31 template DTag(string fName, string tName) {
32 	const char[] DTag = "	
33  auto "~fName~"(string content) { addD(\""~tName~"\", content); return this; }
34  auto "~fName~"(DOPObject content) { addD(\""~tName~"\", content); return this; }
35  auto "~fName~"(STRINGAA values) { addD(\""~tName~"\", values); return this; }
36  auto "~fName~"(STRINGAA values, string content) { addD(\""~tName~"\", values, content); return this; }
37  auto "~fName~"(STRINGAA values, DOPObject content) { addD(\""~tName~"\", values, content); return this; }
38  auto "~fName~"(STRINGAA values, string[] content) { addD(\""~tName~"\", values, content); return this; }
39  auto "~fName~"(STRINGAA values, DOPObject[] content) { addD(\""~tName~"\", values, content); return this; }
40 ";
41 }
42 
43 //class DHTML {
44 //	DHTML listener;
45 //	static DHTML opCall(T...)(T values) { return new DHTML(values); }
46 //	O opCall(this O, T...)(T values) { foreach(v; values) add(v); return cast(O)this; } 
47 //	O opCall(this O)(string value) { add(value); return cast(O)this; } 
48 //	O opCall(this O)(DOPObject value) { add(value); return cast(O)this; } 
49 //
50 //	this(T...)(T values) { this(); add(values); }
51 //	this() { listener = this;}
52 //	// this(DHTML aListener ) { listener = aListener; }
53 ////	this(string entry) { this(); add(entry); }
54 //	// this(string[] entries...) { this(); add(entries); }
55 ////	this(DOPObject entry) { this(); add(entry); }
56 ////	this(DOPObject[] entries...) { this(); add(entries); }
57 //
58 ////	void Add(T...)(T values) { foreach(v; values) Add(v); }
59 ////	void Add(T)(T[] values) { foreach(v; values) Add(v); }
60 ////	void Add(T)(T value) { add(v); }
61 //
62 ////	alias add = super.add;
63 ////	void add(string value) { if (value) add(String(value)); }
64 ////	void add(string[] values) { foreach(value; values) add(String(value)); }
65 ////	override void add(DOPObject value) { if (value) _objects ~= value; }
66 //
67 ////	void addS(string tag) { add("<%s/>".format(tag)); }
68 ////	void addS(string tag, STRINGAA attributes) { add("<%s%s/>".format(tag, attributes.toString)); }
69 //
70 ////	void addD(string tag) { add(doubleTag(tag)); }
71 //////	void addD(string tag, DOPObject[] objs...) { 
72 ////		string result;
73 ////		foreach(c; objs) result ~= c.toString;
74 ////		//add(tag, result);
75 ////	}
76 ////	void addD(string tag, string[] contents...) { addD(tag, contents.join("")); }
77 ////	void addD(string tag, string content) { add(doubleTag(tag, content)); }
78 ////	void addD(string tag, DOPObject content) { add(doubleTag(tag, content.toString));  }
79 //
80 ////	void addD(string tag, STRINGAA attributes) { add(doubleTag(tag, attributes)); }
81 //////	void addD(string tag, STRINGAA attributes, DOPObject[] contents...) { 
82 ////		string result;
83 ////		foreach(c; contents) result ~= c.toString;
84 ////		addD(tag, attributes, result);
85 ////	}
86 ////	void addD(string tag, STRINGAA attributes, string[] contents...) { addD(tag, attributes, contents.join("")); }
87 ////	void addD(string tag, STRINGAA attributes, string content) { addD(tag, attributes, content); }
88 ////	void addD(string tag, STRINGAA attributes, DOPObject content) { addD(tag, attributes, content.toString);  }
89 //
90 ////	string attsToString(STRINGAA atts) {
91 ////		string[] strings;
92 ////		foreach(k, v; atts) strings ~= `%s="%s"`.format(k, v);
93 ////		return strings.join(" ");
94 ////	}
95 ////	auto startTag(string tag, STRINGAA attributes = null) {
96 ////		if (attributes) 
97 ////			return add("<"~tag~" "~aa2String(attributes)~">");
98 ////		else 
99 ////			return add("<"~tag~">");
100 ////	}
101 ////	auto simpleTag(string tag, STRINGAA attributes = null) {
102 ////		if (attributes) 
103 ////			return add("<"~tag~" "~aa2String(attributes)~"/>");
104 ////		else 
105 ////			return add("<"~tag~"/>");
106 ////	}
107 ////	auto endTag(string tag) { return add("</"~tag~">"); }
108 //
109 ////	auto head(T)(T content) { return addD("HEAD", content); }
110 ////	auto head(STRINGAA values) { return addD("HEAD", values); }
111 ////	auto head(T)(STRINGAA values, T content) { return addDTag("HEAD", values, content); }
112 ////
113 ////	auto doctype() {return add("<!DOCTYPE html>"); }
114 ////	auto meta(STRINGAA values) { return addS("META", values); }
115 ////	auto base(STRINGAA values) { return addS("BASE", values); }
116 ////	auto link(STRINGAA values) { return addS("LINK", values); }
117 ////	auto style(T)(T content) { return addD("STYLE", content.toString); }
118 ////	auto style(T:STRINGAA)(T values) { return addD("STYLE", values); }
119 ////	auto style(T)(STRINGAA values, T content) { return addD("STYLE", values, content.toString); }
120 ////	auto style(T:DCSS)(T content) { return addD("STYLE", content.toString); }
121 //
122 ////	mixin(DTag!("script", "Script"));
123 ////	mixin(DTag!("bdy", "BODY"));
124 //
125 //	//	mixin(dTag!("div"));
126 //	//	mixin(dTag!("h1"));
127 //	//	mixin(dTag!("h2"));
128 //	//	mixin(dTag!("h3"));
129 //	//	mixin(dTag!("h4"));
130 //	//	mixin(dTag!("h5"));
131 //	//	mixin(dTag!("h6"));
132 //	//	mixin(dTag!("p"));
133 //	//	mixin(dTag!("span"));
134 //	//	mixin(dTag!("table"));
135 //	//	mixin(dTag!("canvas", "CANVAS"));
136 ////	auto canvas(string id, string width, string height) { return addD("CANVAS", ["id": id, "width": width, "height": height]); }
137 ////	auto canvas(STRINGAA attributes, string id, string width, string height) { 
138 ////		auto atts = attributes;
139 ////		atts["id"] = id;
140 ////		atts["width"] = width;
141 ////		atts["height"] = height;
142 ////		return addD("CANVAS", atts); }
143 //}
144 //
145 
146 unittest {
147 	
148 }