summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2010-09-05 12:50:06 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2010-09-05 12:50:06 -0400
commit1d30544730c4785eef4aabc4a224c03fe1b26983 (patch)
tree48228fa3115dbfd0aa879241a65d8329402ba5f7
parent804444d398bd08b098a941522861d8fb47631d90 (diff)
Support multiple CSS classes for a single tag
-rw-r--r--lib/ur/basis.urs3
-rw-r--r--src/monoize.sml9
-rw-r--r--tests/css.ur6
-rw-r--r--tests/css.urp1
-rw-r--r--tests/css.urs1
5 files changed, 20 insertions, 0 deletions
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs
index 83608d8b..c06482ed 100644
--- a/lib/ur/basis.urs
+++ b/lib/ur/basis.urs
@@ -563,6 +563,9 @@ val setval : sql_sequence -> int -> transaction unit
(** XML *)
type css_class
+val classes : css_class -> css_class -> css_class
+(* The equivalent of writing one class after the other, separated by a space, in
+ * an HTML 'class' attribute *)
con tag :: {Type} -> {Unit} -> {Unit} -> {Type} -> {Type} -> Type
diff --git a/src/monoize.sml b/src/monoize.sml
index b76abb67..cde1af70 100644
--- a/src/monoize.sml
+++ b/src/monoize.sml
@@ -2806,6 +2806,15 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
((L'.ESetval (e1, e2), loc), fm)
end
+ | L.EFfiApp ("Basis", "classes", [s1, s2]) =>
+ let
+ val (s1, fm) = monoExp (env, st, fm) s1
+ val (s2, fm) = monoExp (env, st, fm) s2
+ in
+ ((L'.EStrcat (s1, (L'.EStrcat ((L'.EPrim (Prim.String " "), loc), s2), loc)), loc),
+ fm)
+ end
+
| L.EApp (
(L.ECApp (
(L.ECApp ((L.EFfi ("Basis", "cdata"), _), _), _),
diff --git a/tests/css.ur b/tests/css.ur
new file mode 100644
index 00000000..4218aaae
--- /dev/null
+++ b/tests/css.ur
@@ -0,0 +1,6 @@
+style st1
+style st2
+
+fun main () = return <xml><body>
+ <span title="Whoa" class={classes st1 st2}>Hi!</span>
+</body></xml>
diff --git a/tests/css.urp b/tests/css.urp
new file mode 100644
index 00000000..dac138d9
--- /dev/null
+++ b/tests/css.urp
@@ -0,0 +1 @@
+css
diff --git a/tests/css.urs b/tests/css.urs
new file mode 100644
index 00000000..6ac44e0b
--- /dev/null
+++ b/tests/css.urs
@@ -0,0 +1 @@
+val main : unit -> transaction page