Commit 54d3af2bbee8fbae58970fb9aef8e9dd170c20a4

Authored by totoro
1 parent 56277af9

add "id" and "data" in HTML input attributes

Showing 1 changed file with 8 additions and 1 deletions   Show diff stats
web/CXM_making_a_web_site.anubis
... ... @@ -753,6 +753,7 @@ public type CoreAttrs:
753 753 public define CoreAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false").
754 754  
755 755 public type InputAttrs:
  756 + id (String),
756 757 class (String),
757 758 style (String),
758 759 title (String),
... ... @@ -761,7 +762,9 @@ public type InputAttrs:
761 762 accesskey (Word8),
762 763 tabindex (Int),
763 764 attr (String, String),
764   - event (HtmlEvents, String).
  765 + event (HtmlEvents, String),
  766 + //HTML5
  767 + data (String name, String value).
765 768  
766 769 public define InputAttrs attr(String name, Bool value) = attr(name, if value then "true" else "false").
767 770  
... ... @@ -3225,6 +3228,8 @@ define String
3225 3228 [h . t] then
3226 3229 with current = if h is
3227 3230 {
  3231 + id(id_name) then
  3232 + " id=\"" + id_name + "\"",
3228 3233 class(class_name) then
3229 3234 format_attrs(t, [class_name. classes], styles),
3230 3235 style(style_string) then
... ... @@ -3251,6 +3256,8 @@ define String
3251 3256  
3252 3257 event(e, value) then
3253 3258 " " + event_name(e) + "=\"" + value + "\"",
  3259 + data(name, value) then
  3260 + " data-" + to_lower(name) + "=\"" + value + "\"",
3254 3261 },
3255 3262 current + format_attrs(t, classes, styles)
3256 3263 }.
... ...