Commit 1e9a60855be19425d023c7cf9c48dd82dd83cd2f

Authored by David RENÉ
1 parent 37a7e604

[+] more helper functions for hidden attribute

Showing 1 changed file with 69 additions and 43 deletions   Show diff stats
web/making_a_web_site.anubis
... ... @@ -1476,10 +1476,11 @@ public define CoreAttrs init(String value)= attr("value", encode_HTML_entities(v
1476 1476 //-- BEGIN of <input> preset type
1477 1477  
1478 1478 /// hidden value
1479   -public define HTML hidden(List(CoreAttrs) attrs, String _name, String _value, String form) = input([type(hidden), name(_name), value(encode_HTML_entities(_value)), attr("form", form) . attrs]).
1480   -public define HTML hidden(CoreAttrs attr, String name, String value, String form) = hidden([attr], name, value, form).
1481   -public define HTML hidden(String name, String value, String form) = hidden([], name, value, form).
1482   -public define HTML hidden(String _name, String _value) = input([type(hidden), name(_name), value(encode_HTML_entities(_value))]).
  1479 +public define HTML hidden(List(CoreAttrs) attrs) = input([type(hidden) . attrs]).
  1480 +public define HTML hidden(List(CoreAttrs) attrs, String _name, String _value, String form) = input([type(hidden), name(_name), value(encode_HTML_entities(_value)), attr("form", form) . attrs]).
  1481 +public define HTML hidden(CoreAttrs attr, String name, String value, String form) = hidden([attr], name, value, form).
  1482 +public define HTML hidden(String name, String value, String form) = hidden([], name, value, form).
  1483 +public define HTML hidden(String _name, String _value) = input([type(hidden), name(_name), value(encode_HTML_entities(_value))]).
1483 1484  
1484 1485 public define HTML text_input(List(CoreAttrs) options, HTML_Label label, HTML_Id _id, WebArgName wan, InitialValue init, Int w) =
1485 1486 sequence([
... ... @@ -1852,18 +1853,19 @@ public define HTML th = h
1852 1853 //public define CoreAttrs rowspan(Int value) = attr("rowspan", to_String(value)).
1853 1854 //public define CoreAttrs headers(String header_id) = attr("headers", header_id).
1854 1855  
1855   -public define HTML td(List(CoreAttrs) attrs, List(HTML) content) = html_tag("td", attrs, content).
1856   -public define HTML td(List(CoreAttrs) attrs, HTML content) = html_tag("td", attrs, [content]).
1857   -public define HTML td(CoreAttrs attr, List(HTML) content) = html_tag("td", [attr], content).
1858   -public define HTML td(CoreAttrs attr, HTML content) = html_tag("td", [attr], [content]).
1859   -public define HTML td(List(HTML) content) = html_tag("td", content).
1860   -public define HTML td(HTML content) = html_tag("td", [content]).
1861   -public define HTML td(List(CoreAttrs) attrs, String string) = html_tag("td", attrs, [text(string)]).
1862   -public define HTML td(CoreAttrs attr, String string) = html_tag("td", [attr], [text(string)]).
1863   -public define HTML td(String string) = html_tag("td", [text(string)]).
1864   -public define HTML td(List(CoreAttrs) attrs, Int i) = html_tag("td", attrs, [text(to_decimal(i))]).
1865   -public define HTML td(CoreAttrs attr, Int i) = html_tag("td", [attr], [text(to_decimal(i))]).
1866   -public define HTML td(Int i) = html_tag("td", [text(to_decimal(i))]).
  1856 +public define HTML td(List(CoreAttrs) attrs, List(HTML) content) = html_tag("td", attrs, content).
  1857 +public define HTML td(List(CoreAttrs) attrs, HTML content) = html_tag("td", attrs, [content]).
  1858 +public define HTML td(CoreAttrs attr, List(HTML) content) = html_tag("td", [attr], content).
  1859 +public define HTML td(CoreAttrs attr, HTML content) = html_tag("td", [attr], [content]).
  1860 +public define HTML td(CoreAttrs attr) = html_tag("td", [attr], []).
  1861 +public define HTML td(List(HTML) content) = html_tag("td", [], content).
  1862 +public define HTML td(HTML content) = html_tag("td", [], [content]).
  1863 +public define HTML td(List(CoreAttrs) attrs, String string) = html_tag("td", attrs, [text(string)]).
  1864 +public define HTML td(CoreAttrs attr, String string) = html_tag("td", [attr], [text(string)]).
  1865 +public define HTML td(String string) = html_tag("td", [], [text(string)]).
  1866 +public define HTML td(List(CoreAttrs) attrs, Int i) = html_tag("td", attrs, [text(to_decimal(i))]).
  1867 +public define HTML td(CoreAttrs attr, Int i) = html_tag("td", [attr], [text(to_decimal(i))]).
  1868 +public define HTML td(Int i) = html_tag("td", [], [text(to_decimal(i))]).
1867 1869  
1868 1870 // <tr>
1869 1871 public define HTML tr(List(CoreAttrs) attrs, List(HTML) content) = html_tag("tr", attrs, content).
... ... @@ -1883,23 +1885,7 @@ public define HTML ul(HTML content) = html_tag
1883 1885  
1884 1886 //public define HTML empty = html_tag(
1885 1887  
1886   -//public define HTML
1887   -// form
1888   -// (
1889   -// String form_name,
1890   -// List(CoreAttrs) options,
1891   -// HTML content
1892   -// ) =
1893   -// form([id(form_name). options], [content]).
1894 1888  
1895   -//public define HTML
1896   -// form
1897   -// (
1898   -// String form_name,
1899   -// List(CoreAttrs) options,
1900   -// List(HTML) contents
1901   -// ) =
1902   -// form([id(form_name) . options], contents).
1903 1889  
1904 1890  
1905 1891  
... ... @@ -1914,7 +1900,7 @@ public define HTML
1914 1900 List(CoreAttrs) options,
1915 1901 WEB_Action_Name _action,
1916 1902 List((String,String)) extra_ops,
1917   - HTML content
  1903 + HTML content
1918 1904 ) =
1919 1905 form([action(_action, extra_ops). options], [content]).
1920 1906  
... ... @@ -1922,32 +1908,72 @@ public define HTML
1922 1908 form
1923 1909 (
1924 1910 List(CoreAttrs) options,
1925   - WEB_Action_Name action,
  1911 + WEB_Action_Name _action,
1926 1912 List((String,String)) extra_ops,
1927   - List(HTML) contents
  1913 + List(HTML) contents
1928 1914 ) =
1929   - form(options, action, extra_ops, contents).
  1915 + form([action(_action, extra_ops). options], contents).
1930 1916  
1931 1917 public define HTML
1932 1918 form
1933 1919 (
1934 1920 List(CoreAttrs) options,
1935   - String action,
  1921 + String _action,
  1922 + List((String,String)) extra_ops,
  1923 + HTML content
  1924 + ) =
  1925 + form([action(action_name(_action), extra_ops) . options], [content]).
  1926 +
  1927 +public define HTML
  1928 + form
  1929 + (
  1930 + String form_name,
  1931 + List(CoreAttrs) options,
  1932 + String _action,
1936 1933 List((String,String)) extra_ops,
1937   - HTML content
  1934 + List(HTML) contents
1938 1935 ) =
1939   - form(options, action_name(action), extra_ops, [content]).
  1936 + form([id(form_name), action(action_name(_action), extra_ops) . options], contents).
1940 1937  
1941 1938 public define HTML
1942 1939 form
1943 1940 (
1944 1941 String form_name,
1945 1942 List(CoreAttrs) options,
1946   - String action,
  1943 + WEB_Action_Name _action,
1947 1944 List((String,String)) extra_ops,
1948   - List(HTML) contents
  1945 + List(HTML) contents
1949 1946 ) =
1950   - form(form_name, options, action, extra_ops, contents).
  1947 + form([id(form_name), action(_action, extra_ops). options], contents).
  1948 +
  1949 +public define HTML
  1950 + form
  1951 + (
  1952 + String form_name,
  1953 + List(CoreAttrs) options,
  1954 + WEB_Action_Name _action,
  1955 + List((String,String)) extra_ops,
  1956 + HTML contents
  1957 + ) =
  1958 + form([id(form_name), action(_action, extra_ops). options], [contents]).
  1959 +
  1960 +public define HTML
  1961 + form
  1962 + (
  1963 + String form_name,
  1964 + List(CoreAttrs) options,
  1965 + HTML content
  1966 + ) =
  1967 + form([id(form_name). options], [content]).
  1968 +
  1969 +public define HTML
  1970 + form
  1971 + (
  1972 + String form_name,
  1973 + List(CoreAttrs) options,
  1974 + List(HTML) contents
  1975 + ) =
  1976 + form([id(form_name) . options], contents).
1951 1977  
1952 1978 public define HTML
1953 1979 actioner
... ... @@ -3690,7 +3716,7 @@ define String
3690 3716  
3691 3717 current = if h is
3692 3718 {
3693   - empty then "",
  3719 + //empty then "",
3694 3720 id(id_name) then
3695 3721 " id=\"" + id_name + "\"",
3696 3722 class(class_name) then "", //do nothing here, because we accumulate the class until we have some other attributes
... ...