annotate demo/crud2.ur @ 1840:146ec8e90063

Add some name-mangling rules to allow XML attribute 'name' and attributes with dashes
author Adam Chlipala <adam@chlipala.net>
date Thu, 27 Dec 2012 15:34:11 -0500
parents 669ac5e9a69e
children
rev   line source
adamc@422 1 table t : {Id : int, Nam : string, Ready : bool}
adamc@708 2 PRIMARY KEY Id
adamc@422 3
adamc@422 4 open Crud.Make(struct
adamc@422 5 val tab = t
adamc@422 6
adamc@422 7 val title = "Are you ready?"
adamc@422 8
adamc@422 9 val cols = {Nam = Crud.string "Name",
adamc@422 10 Ready = {Nam = "Ready",
adamc@422 11 Show = (fn b => if b then
adamc@422 12 <xml>Ready!</xml>
adamc@422 13 else
adamc@422 14 <xml>Not ready</xml>),
adamc@823 15 Widget = (fn [nm :: Name] => <xml>
adamc@422 16 <select{nm}>
adamc@422 17 <option>Ready</option>
adamc@422 18 <option>Not ready</option>
adamc@422 19 </select>
adamc@422 20 </xml>),
adamc@823 21 WidgetPopulated = (fn [nm :: Name] b => <xml>
adamc@422 22 <select{nm}>
adamc@422 23 <option selected={b}>Ready</option>
adamc@422 24 <option selected={not b}>Not ready</option>
adamc@422 25 </select>
adamc@422 26 </xml>),
adamc@422 27 Parse = (fn s =>
adamc@422 28 case s of
adamc@422 29 "Ready" => True
adamc@422 30 | "Not ready" => False
adamc@422 31 | _ => error <xml>Invalid ready/not ready</xml>),
adamc@422 32 Inject = _
adamc@422 33 }
adamc@422 34 }
adamc@422 35 end)