Mercurial > urweb
comparison src/monoize.sml @ 2008:93ff76058825
HTML5 data-* attributes
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Fri, 02 May 2014 15:32:10 -0400 |
parents | 67a6ba016a78 |
children | 2b2d07946e65 |
comparison
equal
deleted
inserted
replaced
2007:d3a0f2b8af28 | 2008:93ff76058825 |
---|---|
1 (* Copyright (c) 2008-2013, Adam Chlipala | 1 (* Copyright (c) 2008-2014, Adam Chlipala |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are met: | 5 * modification, are permitted provided that the following conditions are met: |
6 * | 6 * |
233 | L.CFfi ("Basis", "css_style") => (L'.TFfi ("Basis", "string"), loc) | 233 | L.CFfi ("Basis", "css_style") => (L'.TFfi ("Basis", "string"), loc) |
234 | L.CFfi ("Basis", "id") => (L'.TFfi ("Basis", "string"), loc) | 234 | L.CFfi ("Basis", "id") => (L'.TFfi ("Basis", "string"), loc) |
235 | L.CFfi ("Basis", "requestHeader") => (L'.TFfi ("Basis", "string"), loc) | 235 | L.CFfi ("Basis", "requestHeader") => (L'.TFfi ("Basis", "string"), loc) |
236 | L.CFfi ("Basis", "responseHeader") => (L'.TFfi ("Basis", "string"), loc) | 236 | L.CFfi ("Basis", "responseHeader") => (L'.TFfi ("Basis", "string"), loc) |
237 | L.CFfi ("Basis", "envVar") => (L'.TFfi ("Basis", "string"), loc) | 237 | L.CFfi ("Basis", "envVar") => (L'.TFfi ("Basis", "string"), loc) |
238 | L.CFfi ("Basis", "data_attr") => (L'.TFfi ("Basis", "string"), loc) | |
238 | 239 |
239 | L.CApp ((L.CFfi ("Basis", "serialized"), _), _) => | 240 | L.CApp ((L.CFfi ("Basis", "serialized"), _), _) => |
240 (L'.TFfi ("Basis", "string"), loc) | 241 (L'.TFfi ("Basis", "string"), loc) |
241 | 242 |
242 | L.CApp ((L.CFfi ("Basis", "transaction"), _), t) => | 243 | L.CApp ((L.CFfi ("Basis", "transaction"), _), t) => |
3115 in | 3116 in |
3116 ((L'.EStrcat (s1, (L'.EStrcat ((L'.EPrim (Prim.String " "), loc), s2), loc)), loc), | 3117 ((L'.EStrcat (s1, (L'.EStrcat ((L'.EPrim (Prim.String " "), loc), s2), loc)), loc), |
3117 fm) | 3118 fm) |
3118 end | 3119 end |
3119 | 3120 |
3121 | L.EFfiApp ("Basis", "data_attr", [(s1, _), (s2, _)]) => | |
3122 let | |
3123 val (s1, fm) = monoExp (env, st, fm) s1 | |
3124 val (s2, fm) = monoExp (env, st, fm) s2 | |
3125 in | |
3126 ((L'.EStrcat ((L'.EPrim (Prim.String "data-"), loc), | |
3127 (L'.EStrcat ((L'.EFfiApp ("Basis", "blessData", [(s1, (L'.TFfi ("Basis", "string"), loc))]), loc), | |
3128 (L'.EStrcat ((L'.EPrim (Prim.String "=\""), loc), | |
3129 (L'.EStrcat ((L'.EFfiApp ("Basis", "attrifyString", [(s2, (L'.TFfi ("Basis", "string"), loc))]), loc), | |
3130 (L'.EPrim (Prim.String "\""), loc)), loc)), | |
3131 loc)), loc)), loc), | |
3132 fm) | |
3133 end | |
3134 | |
3135 | L.EFfiApp ("Basis", "data_attrs", [(s1, _), (s2, _)]) => | |
3136 let | |
3137 val (s1, fm) = monoExp (env, st, fm) s1 | |
3138 val (s2, fm) = monoExp (env, st, fm) s2 | |
3139 in | |
3140 ((L'.EStrcat (s1, (L'.EStrcat ((L'.EPrim (Prim.String " "), loc), s2), loc)), loc), | |
3141 fm) | |
3142 end | |
3143 | |
3120 | L.EFfiApp ("Basis", "css_url", [(s, _)]) => | 3144 | L.EFfiApp ("Basis", "css_url", [(s, _)]) => |
3121 let | 3145 let |
3122 val (s, fm) = monoExp (env, st, fm) s | 3146 val (s, fm) = monoExp (env, st, fm) s |
3123 in | 3147 in |
3124 ((L'.EStrcat ((L'.EPrim (Prim.String "url("), loc), | 3148 ((L'.EStrcat ((L'.EPrim (Prim.String "url("), loc), |
3315 {disc = t, | 3339 {disc = t, |
3316 result = t}), loc)), loc) | 3340 result = t}), loc)), loc) |
3317 | 3341 |
3318 val (s, fm) = foldl (fn (("Action", _, _), acc) => acc | 3342 val (s, fm) = foldl (fn (("Action", _, _), acc) => acc |
3319 | (("Source", _, _), acc) => acc | 3343 | (("Source", _, _), acc) => acc |
3344 | (("Data", e, _), (s, fm)) => | |
3345 ((L'.EStrcat (s, | |
3346 (L'.EStrcat ( | |
3347 (L'.EPrim (Prim.String " "), loc), | |
3348 e), loc)), loc), | |
3349 fm) | |
3320 | ((x, e, t), (s, fm)) => | 3350 | ((x, e, t), (s, fm)) => |
3321 case t of | 3351 case t of |
3322 (L'.TFfi ("Basis", "bool"), _) => | 3352 (L'.TFfi ("Basis", "bool"), _) => |
3323 let | 3353 let |
3324 val s' = " " ^ lowercaseFirst x | 3354 val s' = " " ^ lowercaseFirst x |