From 1e9a60855be19425d023c7cf9c48dd82dd83cd2f Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 10 May 2026 13:39:45 +0900 Subject: [PATCH] [+] more helper functions for hidden attribute --- web/making_a_web_site.anubis | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------- 1 file changed, 69 insertions(+), 43 deletions(-) diff --git a/web/making_a_web_site.anubis b/web/making_a_web_site.anubis index 4d7c893..92ed4e0 100644 --- a/web/making_a_web_site.anubis +++ b/web/making_a_web_site.anubis @@ -1476,10 +1476,11 @@ public define CoreAttrs init(String value)= attr("value", encode_HTML_entities(v //-- BEGIN of preset type /// hidden value -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]). -public define HTML hidden(CoreAttrs attr, String name, String value, String form) = hidden([attr], name, value, form). -public define HTML hidden(String name, String value, String form) = hidden([], name, value, form). -public define HTML hidden(String _name, String _value) = input([type(hidden), name(_name), value(encode_HTML_entities(_value))]). +public define HTML hidden(List(CoreAttrs) attrs) = input([type(hidden) . attrs]). +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]). +public define HTML hidden(CoreAttrs attr, String name, String value, String form) = hidden([attr], name, value, form). +public define HTML hidden(String name, String value, String form) = hidden([], name, value, form). +public define HTML hidden(String _name, String _value) = input([type(hidden), name(_name), value(encode_HTML_entities(_value))]). public define HTML text_input(List(CoreAttrs) options, HTML_Label label, HTML_Id _id, WebArgName wan, InitialValue init, Int w) = sequence([ @@ -1852,18 +1853,19 @@ public define HTML th = h //public define CoreAttrs rowspan(Int value) = attr("rowspan", to_String(value)). //public define CoreAttrs headers(String header_id) = attr("headers", header_id). -public define HTML td(List(CoreAttrs) attrs, List(HTML) content) = html_tag("td", attrs, content). -public define HTML td(List(CoreAttrs) attrs, HTML content) = html_tag("td", attrs, [content]). -public define HTML td(CoreAttrs attr, List(HTML) content) = html_tag("td", [attr], content). -public define HTML td(CoreAttrs attr, HTML content) = html_tag("td", [attr], [content]). -public define HTML td(List(HTML) content) = html_tag("td", content). -public define HTML td(HTML content) = html_tag("td", [content]). -public define HTML td(List(CoreAttrs) attrs, String string) = html_tag("td", attrs, [text(string)]). -public define HTML td(CoreAttrs attr, String string) = html_tag("td", [attr], [text(string)]). -public define HTML td(String string) = html_tag("td", [text(string)]). -public define HTML td(List(CoreAttrs) attrs, Int i) = html_tag("td", attrs, [text(to_decimal(i))]). -public define HTML td(CoreAttrs attr, Int i) = html_tag("td", [attr], [text(to_decimal(i))]). -public define HTML td(Int i) = html_tag("td", [text(to_decimal(i))]). +public define HTML td(List(CoreAttrs) attrs, List(HTML) content) = html_tag("td", attrs, content). +public define HTML td(List(CoreAttrs) attrs, HTML content) = html_tag("td", attrs, [content]). +public define HTML td(CoreAttrs attr, List(HTML) content) = html_tag("td", [attr], content). +public define HTML td(CoreAttrs attr, HTML content) = html_tag("td", [attr], [content]). +public define HTML td(CoreAttrs attr) = html_tag("td", [attr], []). +public define HTML td(List(HTML) content) = html_tag("td", [], content). +public define HTML td(HTML content) = html_tag("td", [], [content]). +public define HTML td(List(CoreAttrs) attrs, String string) = html_tag("td", attrs, [text(string)]). +public define HTML td(CoreAttrs attr, String string) = html_tag("td", [attr], [text(string)]). +public define HTML td(String string) = html_tag("td", [], [text(string)]). +public define HTML td(List(CoreAttrs) attrs, Int i) = html_tag("td", attrs, [text(to_decimal(i))]). +public define HTML td(CoreAttrs attr, Int i) = html_tag("td", [attr], [text(to_decimal(i))]). +public define HTML td(Int i) = html_tag("td", [], [text(to_decimal(i))]). // 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 //public define HTML empty = html_tag( -//public define HTML -// form -// ( -// String form_name, -// List(CoreAttrs) options, -// HTML content -// ) = -// form([id(form_name). options], [content]). -//public define HTML -// form -// ( -// String form_name, -// List(CoreAttrs) options, -// List(HTML) contents -// ) = -// form([id(form_name) . options], contents). @@ -1914,7 +1900,7 @@ public define HTML List(CoreAttrs) options, WEB_Action_Name _action, List((String,String)) extra_ops, - HTML content + HTML content ) = form([action(_action, extra_ops). options], [content]). @@ -1922,32 +1908,72 @@ public define HTML form ( List(CoreAttrs) options, - WEB_Action_Name action, + WEB_Action_Name _action, List((String,String)) extra_ops, - List(HTML) contents + List(HTML) contents ) = - form(options, action, extra_ops, contents). + form([action(_action, extra_ops). options], contents). public define HTML form ( List(CoreAttrs) options, - String action, + String _action, + List((String,String)) extra_ops, + HTML content + ) = + form([action(action_name(_action), extra_ops) . options], [content]). + +public define HTML + form + ( + String form_name, + List(CoreAttrs) options, + String _action, List((String,String)) extra_ops, - HTML content + List(HTML) contents ) = - form(options, action_name(action), extra_ops, [content]). + form([id(form_name), action(action_name(_action), extra_ops) . options], contents). public define HTML form ( String form_name, List(CoreAttrs) options, - String action, + WEB_Action_Name _action, List((String,String)) extra_ops, - List(HTML) contents + List(HTML) contents ) = - form(form_name, options, action, extra_ops, contents). + form([id(form_name), action(_action, extra_ops). options], contents). + +public define HTML + form + ( + String form_name, + List(CoreAttrs) options, + WEB_Action_Name _action, + List((String,String)) extra_ops, + HTML contents + ) = + form([id(form_name), action(_action, extra_ops). options], [contents]). + +public define HTML + form + ( + String form_name, + List(CoreAttrs) options, + HTML content + ) = + form([id(form_name). options], [content]). + +public define HTML + form + ( + String form_name, + List(CoreAttrs) options, + List(HTML) contents + ) = + form([id(form_name) . options], contents). public define HTML actioner @@ -3690,7 +3716,7 @@ define String current = if h is { - empty then "", + //empty then "", id(id_name) then " id=\"" + id_name + "\"", class(class_name) then "", //do nothing here, because we accumulate the class until we have some other attributes -- libgit2 0.21.4