summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-07-24 11:16:54 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-07-24 11:16:54 -0400
commit5f895c17f35466d10ef80cd7146638d8505e4e9b (patch)
treef841aca63a6b80672762ff18a2a49a6630caa446
parent6f1206729039e45e032c5ba7f04d072f41dc9961 (diff)
HTML select
-rw-r--r--lib/basis.lig4
-rw-r--r--src/monoize.sml14
-rw-r--r--tests/select.lac13
3 files changed, 31 insertions, 0 deletions
diff --git a/lib/basis.lig b/lib/basis.lig
index 8b41b8f6..913e6af4 100644
--- a/lib/basis.lig
+++ b/lib/basis.lig
@@ -72,6 +72,10 @@ con radio = [Body, Radio]
val radio : lformTag string radio []
val radioOption : unit -> tag [Value = string] radio [] [] []
+con select = [Select]
+val lselect : lformTag string select []
+val loption : unit -> tag [Value = string] select [] [] []
+
val submit : ctx ::: {Unit} -> [LForm] ~ ctx
-> use ::: {Type} -> unit
-> tag [Action = $use -> page] ([LForm] ++ ctx) ([LForm] ++ ctx) use []
diff --git a/src/monoize.sml b/src/monoize.sml
index 3bcb9e83..c193e611 100644
--- a/src/monoize.sml
+++ b/src/monoize.sml
@@ -329,6 +329,20 @@ fun monoExp (env, st) (all as (e, loc)) =
normal ("input",
SOME (L'.EPrim (Prim.String (" type=\"radio\" name=\"" ^ name ^ "\"")), loc)))
+ | "lselect" =>
+ (case targs of
+ [_, (L.CName name, _)] =>
+ (L'.EStrcat ((L'.EStrcat (tagStart "select",
+ (L'.EPrim (Prim.String (" name=\"" ^ name ^ "\">")), loc)), loc),
+ (L'.EStrcat (monoExp (env, st) xml,
+ (L'.EPrim (Prim.String "</select>"),
+ loc)), loc)),
+ loc)
+ | _ => (Print.prefaces "Targs" (map (fn t => ("T", CorePrint.p_con env t)) targs);
+ raise Fail "No name passed to lselect tag"))
+
+ | "loption" => normal ("option", NONE)
+
| _ => normal (tag, NONE)
end
diff --git a/tests/select.lac b/tests/select.lac
new file mode 100644
index 00000000..d97e6a55
--- /dev/null
+++ b/tests/select.lac
@@ -0,0 +1,13 @@
+val handler = fn x => <html><body>
+ You entered: {cdata x.A}
+</body></html>
+
+val main = fn () => <html><body>
+ <lform>
+ <lselect{#A}>
+ <loption value="A">A</loption>
+ <loption value="B">B</loption>
+ </lselect>
+ <submit action={handler}/>
+ </lform>
+</body></html>