summaryrefslogtreecommitdiff
path: root/src/urweb.grm
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2012-12-27 15:34:11 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2012-12-27 15:34:11 -0500
commit53c633b53e8825cb9058fb88e86d1ca7828b83e6 (patch)
tree94682452c654491c184a8e2d43d3dbfdb4e46cf9 /src/urweb.grm
parentbf6fbd81d4e60a87b19f8c8149349217b4620360 (diff)
Add some name-mangling rules to allow XML attribute 'name' and attributes with dashes
Diffstat (limited to 'src/urweb.grm')
-rw-r--r--src/urweb.grm11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/urweb.grm b/src/urweb.grm
index a45c7ffa..c2a48742 100644
--- a/src/urweb.grm
+++ b/src/urweb.grm
@@ -35,6 +35,12 @@ val dummy = ErrorMsg.dummySpan
fun capitalize "" = ""
| capitalize s = str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE)
+fun makeAttr s =
+ case s of
+ "type" => "Typ"
+ | "name" => "Nam"
+ | _ => capitalize (String.translate (fn ch => if ch = #"-" then "_" else str ch) s)
+
fun entable t =
case #1 t of
TRecord c => c
@@ -1648,10 +1654,7 @@ attr : SYMBOL EQ attrv (case SYMBOL of
| "dynStyle" => DynStyle attrv
| _ =>
let
- val sym =
- case SYMBOL of
- "type" => "Typ"
- | x => capitalize x
+ val sym = makeAttr SYMBOL
in
Normal ((CName sym, s (SYMBOLleft, SYMBOLright)),
if (sym = "Href" orelse sym = "Src")