From 1841386c2ad439363d735acc0550c495e040d217 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 16 Apr 2009 12:00:44 -0400 Subject: --- lib/ur/basis.urs | 6 ++++-- src/monoize.sml | 4 ++++ src/urweb.grm | 33 ++++++++++++++++++++------------- tests/style.ur | 11 ++++++++--- 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 - Hi. And hi again! - +fun main () : transaction page = return + + + + + Hi. And hi again! + + -- cgit v1.2.3