Commit eccfbd576af85fd5e1e25a2c81352ff4a4ed1b2d
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 | 1308 | |
| 1309 | 1309 | |
| 1310 | 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 | 1324 | public define HTML_Off_Form text(List(CoreAttrs) attrs, Int i) = text(attrs, to_decimal(i)). |
| 1313 | 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 | 1456 | public define HTML_Off_Form form(CoreAttrs attr, HTML_Off_Form content) = html_tag("form", [attr], [content]). |
| 1445 | 1457 | public define HTML_Off_Form form(List(CoreAttrs) attrs) = html_tag("form", attrs, []). |
| 1446 | 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 | 1461 | // <header> |
| 1449 | 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 | 1512 | public define HTML_Off_Form input(List(CoreAttrs) attrs) = html_void_tag("input", attrs). |
| 1500 | 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 | 1519 | //-- BEGIN of <input> preset type |
| 1503 | 1520 | |
| 1504 | 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 | 1523 | public define HTML_Off_Form radio(List(CoreAttrs) attrs, String name, String value, String form) = radio(attrs, name, value, form, false). |
| 1507 | 1524 | public define HTML_Off_Form radio(String name, String value, String form, Bool checked) = radio([], name, value, form, checked). |
| 1508 | 1525 | public define HTML_Off_Form radio(String name, String value, String form) = radio([], name, value, form, false). |
| 1509 | 1526 | |
| 1510 | 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 | 1529 | public define HTML_Off_Form hidden(CoreAttrs attr, String name, String value, String form) = hidden([attr], name, value, form). |
| 1513 | 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 | 1533 | //-- END of <input> preset type |
| 1517 | 1534 | |
| ... | ... | @@ -1589,11 +1606,14 @@ public define HTML_Off_Form pre(List(CoreAttrs) attrs, String string) |
| 1589 | 1606 | // <progress> |
| 1590 | 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 | 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 | 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 | 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 | 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 | 1619 | // <section> |
| ... | ... | @@ -1621,6 +1641,8 @@ public define HTML_Off_Form span(Int i) |
| 1621 | 1641 | public define HTML_Off_Form span(List(CoreAttrs) attrs, String s) = html_tag("span", attrs, [text(s)]). |
| 1622 | 1642 | public define HTML_Off_Form span(CoreAttrs attr, String s) = html_tag("span", [attr],[text(s)]). |
| 1623 | 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 | 1647 | // <strong> |
| 1626 | 1648 | public define HTML_Off_Form strong(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("strong", attrs, content). | ... | ... |