summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-04-16 12:00:44 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-04-16 12:00:44 -0400
commit1841386c2ad439363d735acc0550c495e040d217 (patch)
treeceb56cba54a598fb80b02bc10a82b394c3aa3a06
parentf03c559d279c0026be2aa781fdef26ea9d5298b5 (diff)
<link>
-rw-r--r--lib/ur/basis.urs6
-rw-r--r--src/monoize.sml4
-rw-r--r--src/urweb.grm33
-rw-r--r--tests/style.ur11
4 files changed, 36 insertions, 18 deletions
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs
index 50146dde..cfb80850 100644
--- a/lib/ur/basis.urs
+++ b/lib/ur/basis.urs
@@ -452,11 +452,15 @@ con form = [Body, Form]
con tabl = [Body, Table]
con tr = [Body, Tr]
+type url
+val bless : string -> url
+
val dyn : use ::: {Type} -> bind ::: {Type} -> unit
-> tag [Signal = signal (xml body use bind)] body [] use bind
val head : unit -> tag [] html head [] []
val title : unit -> tag [] head [] [] []
+val link : unit -> tag [Rel = string, Typ = string, Href = url, Media = string] head [] [] []
val body : unit -> tag [Onload = transaction unit] html body [] []
con bodyTag = fn (attrs :: {Type}) =>
@@ -489,8 +493,6 @@ val ul : bodyTag []
val hr : bodyTag []
-type url
-val bless : string -> url
val a : bodyTag [Link = transaction page, Href = url, Onclick = transaction unit]
val img : bodyTag [Src = url]
diff --git a/src/monoize.sml b/src/monoize.sml
index 51fae113..3fd4f730 100644
--- a/src/monoize.sml
+++ b/src/monoize.sml
@@ -2168,6 +2168,10 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
| "Action" => urlifyExp
| _ => attrifyExp
+ val x =
+ case x of
+ "Typ" => "Type"
+ | _ => x
val xp = " " ^ lowercaseFirst x ^ "=\""
val (e, fm) = fooify env fm (e, t)
diff --git a/src/urweb.grm b/src/urweb.grm
index d47aaf47..50d0c803 100644
--- a/src/urweb.grm
+++ b/src/urweb.grm
@@ -1308,19 +1308,26 @@ attrs : (NONE, [])
attr : SYMBOL EQ attrv (if SYMBOL = "class" then
Class attrv
else
- Normal ((CName (capitalize SYMBOL), s (SYMBOLleft, SYMBOLright)),
- if (SYMBOL = "href" orelse SYMBOL = "src")
- andalso (case #1 attrv of
- EPrim _ => true
- | _ => false) then
- let
- val loc = s (attrvleft, attrvright)
- in
- (EApp ((EVar (["Basis"], "bless", Infer), loc),
- attrv), loc)
- end
- else
- attrv))
+ let
+ val sym =
+ case SYMBOL of
+ "type" => "Typ"
+ | x => capitalize x
+ in
+ Normal ((CName sym, s (SYMBOLleft, SYMBOLright)),
+ if (sym = "Href" orelse sym = "Src")
+ andalso (case #1 attrv of
+ EPrim _ => true
+ | _ => false) then
+ let
+ val loc = s (attrvleft, attrvright)
+ in
+ (EApp ((EVar (["Basis"], "bless", Infer), loc),
+ attrv), loc)
+ end
+ else
+ attrv)
+ end)
attrv : INT (EPrim (Prim.Int INT), s (INTleft, INTright))
| FLOAT (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright))
diff --git a/tests/style.ur b/tests/style.ur
index 29a8f262..8a5c114c 100644
--- a/tests/style.ur
+++ b/tests/style.ur
@@ -1,6 +1,11 @@
style q
style r
-fun main () : transaction page = return <xml><body>
- Hi. <span class={q}>And hi <span class={r}>again</span>!</span>
-</body></xml>
+fun main () : transaction page = return <xml>
+ <head>
+ <link rel="stylesheet" type="text/css" href="http://www.schizomaniac.net/style.css" media="screen"/>
+ </head>
+ <body>
+ Hi. <span class={q}>And hi <span class={r}>again</span>!</span>
+ </body>
+</xml>