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
commit0d0542b8a16dab4df999df580c78dfe52a340363 (patch)
tree94682452c654491c184a8e2d43d3dbfdb4e46cf9 /src/urweb.grm
parent82cbf5f313810ccaad6415e4488a509e64872eff (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")