Last active
August 29, 2015 14:09
-
-
Save joeriks/e0325d118f07cbb372b4 to your computer and use it in GitHub Desktop.
the zero locs html template . anonymous types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Func<string, string> tag(string tag) | |
{ | |
return new Func<string, string>(s => | |
{ | |
return string.Format("<{0}>{1}</{0}>", tag, s); | |
}); | |
} | |
public Func<string, string> tagAttr(string tag, string attrName) | |
{ | |
return new Func<string, string>(s => | |
{ | |
return string.Format("<{0} {2}='{1}'/>", tag, s, attrName); | |
}); | |
} | |
public Func<T, string> comp<T>(T defaultValues, Func<T, string> composer) | |
{ | |
return composer; | |
} | |
void Main() | |
{ | |
var header = tag("h1"); | |
var div = tag("div"); | |
var label = tag("label"); | |
var input = tagAttr("input","placeholder"); | |
var labelinput = comp(new {label="", placeholder=""}, c=>{ | |
return string.Concat( | |
div( | |
string.Concat( | |
label(c.label), | |
input(c.placeholder) | |
) | |
) | |
); | |
}); | |
var page = string.Concat( | |
header("Sample:"), | |
labelinput(new {label="Name:", placeholder="enter something"}), | |
labelinput(new {label="Address:", placeholder="enter something"}) | |
); | |
Util.RawHtml(page).Dump(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Sample:</h1> | |
<div> | |
<label>Name:</label> | |
<input placeholder="enter something" /> | |
</div> | |
<div> | |
<label>Address:</label> | |
<input placeholder="enter something" /> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment