Commit eccfbd576af85fd5e1e25a2c81352ff4a4ed1b2d

Authored by David RENÉ
1 parent 37b9bddb

[+] add many helpers for CoreAttrs and html_tag

Showing 1 changed file with 27 additions and 5 deletions   Show diff stats
web/making_a_web_site.anubis
@@ -1308,6 +1308,18 @@ week @@ -1308,6 +1308,18 @@ week
1308 1308
1309 1309
1310 'HTML_Off_Form' defines all the elements you may put outside any form. 1310 'HTML_Off_Form' defines all the elements you may put outside any form.
  1311 +
  1312 +public define CoreAttrs method(String value) = attr("method", value).
  1313 +public define CoreAttrs for(String value) = attr("for", value).
  1314 +public define CoreAttrs placeholder(String value) = attr("placeholder", value).
  1315 +public define CoreAttrs action(WEB_Action_Name action)= attr("action", "/"+format_web_action_name(action)).
  1316 +public define CoreAttrs action(WEB_Action_Name action, List((String,String)) extra_ops)= attr("formaction", "/"+format_web_action_name(action, extra_ops)).
  1317 +public define CoreAttrs formaction(WEB_Action_Name action)= attr("action", "/"+format_web_action_name(action)).
  1318 +public define CoreAttrs formaction(WEB_Action_Name action, List((String,String)) extra_ops)= attr("formaction", "/"+format_web_action_name(action, extra_ops)).
  1319 +public define CoreAttrs formmethod(String value) = attr("formmethod", value).
  1320 +public define CoreAttrs form(String value) = attr("form", value).
  1321 +
  1322 +
1311 1323
1312 public define HTML_Off_Form text(List(CoreAttrs) attrs, Int i) = text(attrs, to_decimal(i)). 1324 public define HTML_Off_Form text(List(CoreAttrs) attrs, Int i) = text(attrs, to_decimal(i)).
1313 public define HTML_Off_Form text(CoreAttrs attr, Int i) = text([attr], i). 1325 public define HTML_Off_Form text(CoreAttrs attr, Int i) = text([attr], i).
@@ -1444,6 +1456,7 @@ public define HTML_Off_Form form(CoreAttrs attr, List(HTML_Off_Form) content) @@ -1444,6 +1456,7 @@ public define HTML_Off_Form form(CoreAttrs attr, List(HTML_Off_Form) content)
1444 public define HTML_Off_Form form(CoreAttrs attr, HTML_Off_Form content) = html_tag("form", [attr], [content]). 1456 public define HTML_Off_Form form(CoreAttrs attr, HTML_Off_Form content) = html_tag("form", [attr], [content]).
1445 public define HTML_Off_Form form(List(CoreAttrs) attrs) = html_tag("form", attrs, []). 1457 public define HTML_Off_Form form(List(CoreAttrs) attrs) = html_tag("form", attrs, []).
1446 public define HTML_Off_Form form(CoreAttrs attr) = html_tag("form", [attr], []). 1458 public define HTML_Off_Form form(CoreAttrs attr) = html_tag("form", [attr], []).
  1459 +public define HTML_Off_Form form(List(HTML_Off_Form) content) = html_tag("form", [], content).
1447 1460
1448 // <header> 1461 // <header>
1449 public define HTML_Off_Form header(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("header", attrs, content). 1462 public define HTML_Off_Form header(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("header", attrs, content).
@@ -1499,19 +1512,23 @@ public define HTML_Off_Form iframe(String src) @@ -1499,19 +1512,23 @@ public define HTML_Off_Form iframe(String src)
1499 public define HTML_Off_Form input(List(CoreAttrs) attrs) = html_void_tag("input", attrs). 1512 public define HTML_Off_Form input(List(CoreAttrs) attrs) = html_void_tag("input", attrs).
1500 public define HTML_Off_Form input(CoreAttrs attr) = html_void_tag("input", [attr]). 1513 public define HTML_Off_Form input(CoreAttrs attr) = html_void_tag("input", [attr]).
1501 1514
  1515 +public define CoreAttrs type(String value)= attr("type", value).
  1516 +public define CoreAttrs name(String value)= attr("name", value).
  1517 +public define CoreAttrs value(String value)= attr("value", value).
  1518 +
1502 //-- BEGIN of <input> preset type 1519 //-- BEGIN of <input> preset type
1503 1520
1504 /// Radio button 1521 /// Radio button
1505 -public define HTML_Off_Form radio(List(CoreAttrs) attrs, String name, String value, String form, Bool checked) = input([attr("type","radio"), attr("name",name), attr("value",value), attr("form", form), bool_attr(checked, "checked") . attrs]). 1522 +public define HTML_Off_Form radio(List(CoreAttrs) attrs, String name, String value, String form, Bool checked) = input([type("radio"), attr("name",name), attr("value",value), attr("form", form), bool_attr(checked, "checked") . attrs]).
1506 public define HTML_Off_Form radio(List(CoreAttrs) attrs, String name, String value, String form) = radio(attrs, name, value, form, false). 1523 public define HTML_Off_Form radio(List(CoreAttrs) attrs, String name, String value, String form) = radio(attrs, name, value, form, false).
1507 public define HTML_Off_Form radio(String name, String value, String form, Bool checked) = radio([], name, value, form, checked). 1524 public define HTML_Off_Form radio(String name, String value, String form, Bool checked) = radio([], name, value, form, checked).
1508 public define HTML_Off_Form radio(String name, String value, String form) = radio([], name, value, form, false). 1525 public define HTML_Off_Form radio(String name, String value, String form) = radio([], name, value, form, false).
1509 1526
1510 /// hidden value 1527 /// hidden value
1511 -public define HTML_Off_Form hidden(List(CoreAttrs) attrs, String name, String value, String form) = input([attr("type","hidden"), attr("name",name), attr("value",value), attr("form", form) . attrs]). 1528 +public define HTML_Off_Form hidden(List(CoreAttrs) attrs, String name, String value, String form) = input([type("hidden"), attr("name",name), attr("value",value), attr("form", form) . attrs]).
1512 public define HTML_Off_Form hidden(CoreAttrs attr, String name, String value, String form) = hidden([attr], name, value, form). 1529 public define HTML_Off_Form hidden(CoreAttrs attr, String name, String value, String form) = hidden([attr], name, value, form).
1513 public define HTML_Off_Form hidden(String name, String value, String form) = hidden([], name, value, form). 1530 public define HTML_Off_Form hidden(String name, String value, String form) = hidden([], name, value, form).
1514 -public define HTML_Off_Form hidden(String name, String value) = input([attr("type","hidden"), attr("name",name), attr("value",value)]). 1531 +public define HTML_Off_Form hidden(String _name, String _value) = input([type("hidden"), name(_name), value(_value)]).
1515 1532
1516 //-- END of <input> preset type 1533 //-- END of <input> preset type
1517 1534
@@ -1589,11 +1606,14 @@ public define HTML_Off_Form pre(List(CoreAttrs) attrs, String string) @@ -1589,11 +1606,14 @@ public define HTML_Off_Form pre(List(CoreAttrs) attrs, String string)
1589 // <progress> 1606 // <progress>
1590 public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max, List(HTML_Off_Form) content) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], content). 1607 public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max, List(HTML_Off_Form) content) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], content).
1591 public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], [content]). 1608 public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], [content]).
1592 -public define HTML_Off_Form progress(CoreAttrs _attr, Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max) , _attr], [content]). 1609 +public define HTML_Off_Form progress(CoreAttrs _attr, Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max) , _attr], [content]).
1593 public define HTML_Off_Form progress(Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max)], [content]). 1610 public define HTML_Off_Form progress(Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max)], [content]).
1594 public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], [text(content)]). 1611 public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], [text(content)]).
1595 -public define HTML_Off_Form progress(CoreAttrs _attr, Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max), _attr], [text(content)]). 1612 +public define HTML_Off_Form progress(CoreAttrs _attr, Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max), _attr], [text(content)]).
  1613 +public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], []).
  1614 +public define HTML_Off_Form progress(CoreAttrs _attr, Int value, Int max) = html_tag("progress", [attr("value", value), attr("max", max), _attr], []).
1596 public define HTML_Off_Form progress(Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max)], [text(content)]). 1615 public define HTML_Off_Form progress(Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max)], [text(content)]).
  1616 +public define HTML_Off_Form progress(Int value, Int max) = html_tag("progress", [attr("value", value), attr("max", max)], []).
1597 1617
1598 1618
1599 // <section> 1619 // <section>
@@ -1621,6 +1641,8 @@ public define HTML_Off_Form span(Int i) @@ -1621,6 +1641,8 @@ public define HTML_Off_Form span(Int i)
1621 public define HTML_Off_Form span(List(CoreAttrs) attrs, String s) = html_tag("span", attrs, [text(s)]). 1641 public define HTML_Off_Form span(List(CoreAttrs) attrs, String s) = html_tag("span", attrs, [text(s)]).
1622 public define HTML_Off_Form span(CoreAttrs attr, String s) = html_tag("span", [attr],[text(s)]). 1642 public define HTML_Off_Form span(CoreAttrs attr, String s) = html_tag("span", [attr],[text(s)]).
1623 public define HTML_Off_Form span(String s) = html_tag("span", [], [text(s)]). 1643 public define HTML_Off_Form span(String s) = html_tag("span", [], [text(s)]).
  1644 +public define HTML_Off_Form span(List(CoreAttrs) attrs) = html_tag("span", attrs, []).
  1645 +public define HTML_Off_Form span(CoreAttrs attr) = html_tag("span", [attr],[]).
1624 1646
1625 // <strong> 1647 // <strong>
1626 public define HTML_Off_Form strong(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("strong", attrs, content). 1648 public define HTML_Off_Form strong(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("strong", attrs, content).