1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
|
let products =
[ 1, "Tea", 2.3M;
2, "Coffee", 5.0M;
3, "Lemonade", 1.5M ]
[<View>]
let footer () =
h.contentTemplate {
h?hr
h?div.set("id", "footer") {
h.content
}
}
[<View>]
let item (id, name, price) str =
h.template {
h?li {
h?strong {
html.ActionLink(name, "details", route [ "id", id ])
}
!> " - Price: %s%f" str price
}
}
[<View>]
let index () =
let title = "Product Listing"
h?html {
h?head {
h?title {
!> "%s - View Engine Sample" title
}
h?link.set("typ", "text/css").set("rel", "stylesheet").set("href", "/Content/Site.css")
}
h?div.set("id", "main") {
h?h1 { title }
h?hr.set("cssclass", "heading")
h?div {
h?ul.set("cssclass", "listing") {
for prod in products do
item prod "$"
}
}
footer() {
"This is an example of using "
h?a.set("href", "http://fsharp.net") {
"the amazing F# language"
}
@" for writing a simple an elegant view engine
for the ASP.NET MVC framework"
}
}
}
|