From eccfbd576af85fd5e1e25a2c81352ff4a4ed1b2d Mon Sep 17 00:00:00 2001 From: totoro Date: Fri, 5 May 2023 11:06:51 +0900 Subject: [PATCH] [+] add many helpers for CoreAttrs and html_tag --- web/making_a_web_site.anubis | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/web/making_a_web_site.anubis b/web/making_a_web_site.anubis index 0f5c670..3713b7c 100644 --- a/web/making_a_web_site.anubis +++ b/web/making_a_web_site.anubis @@ -1308,6 +1308,18 @@ week 'HTML_Off_Form' defines all the elements you may put outside any form. + +public define CoreAttrs method(String value) = attr("method", value). +public define CoreAttrs for(String value) = attr("for", value). +public define CoreAttrs placeholder(String value) = attr("placeholder", value). +public define CoreAttrs action(WEB_Action_Name action)= attr("action", "/"+format_web_action_name(action)). +public define CoreAttrs action(WEB_Action_Name action, List((String,String)) extra_ops)= attr("formaction", "/"+format_web_action_name(action, extra_ops)). +public define CoreAttrs formaction(WEB_Action_Name action)= attr("action", "/"+format_web_action_name(action)). +public define CoreAttrs formaction(WEB_Action_Name action, List((String,String)) extra_ops)= attr("formaction", "/"+format_web_action_name(action, extra_ops)). +public define CoreAttrs formmethod(String value) = attr("formmethod", value). +public define CoreAttrs form(String value) = attr("form", value). + + public define HTML_Off_Form text(List(CoreAttrs) attrs, Int i) = text(attrs, to_decimal(i)). 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) public define HTML_Off_Form form(CoreAttrs attr, HTML_Off_Form content) = html_tag("form", [attr], [content]). public define HTML_Off_Form form(List(CoreAttrs) attrs) = html_tag("form", attrs, []). public define HTML_Off_Form form(CoreAttrs attr) = html_tag("form", [attr], []). +public define HTML_Off_Form form(List(HTML_Off_Form) content) = html_tag("form", [], content). //
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) public define HTML_Off_Form input(List(CoreAttrs) attrs) = html_void_tag("input", attrs). public define HTML_Off_Form input(CoreAttrs attr) = html_void_tag("input", [attr]). +public define CoreAttrs type(String value)= attr("type", value). +public define CoreAttrs name(String value)= attr("name", value). +public define CoreAttrs value(String value)= attr("value", value). + //-- BEGIN of preset type /// Radio button -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]). +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]). public define HTML_Off_Form radio(List(CoreAttrs) attrs, String name, String value, String form) = radio(attrs, name, value, form, false). public define HTML_Off_Form radio(String name, String value, String form, Bool checked) = radio([], name, value, form, checked). public define HTML_Off_Form radio(String name, String value, String form) = radio([], name, value, form, false). /// hidden value -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]). +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]). public define HTML_Off_Form hidden(CoreAttrs attr, String name, String value, String form) = hidden([attr], name, value, form). public define HTML_Off_Form hidden(String name, String value, String form) = hidden([], name, value, form). -public define HTML_Off_Form hidden(String name, String value) = input([attr("type","hidden"), attr("name",name), attr("value",value)]). +public define HTML_Off_Form hidden(String _name, String _value) = input([type("hidden"), name(_name), value(_value)]). //-- END of preset type @@ -1589,11 +1606,14 @@ public define HTML_Off_Form pre(List(CoreAttrs) attrs, String string) // 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). 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]). -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]). +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]). public define HTML_Off_Form progress(Int value, Int max, HTML_Off_Form content) = html_tag("progress", [attr("value", value), attr("max", max)], [content]). 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)]). -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)]). +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)]). +public define HTML_Off_Form progress(List(CoreAttrs) attrs, Int value, Int max) = html_tag("progress", [attr("value", value), attr("max", max) . attrs], []). +public define HTML_Off_Form progress(CoreAttrs _attr, Int value, Int max) = html_tag("progress", [attr("value", value), attr("max", max), _attr], []). public define HTML_Off_Form progress(Int value, Int max, String content) = html_tag("progress", [attr("value", value), attr("max", max)], [text(content)]). +public define HTML_Off_Form progress(Int value, Int max) = html_tag("progress", [attr("value", value), attr("max", max)], []). //
@@ -1621,6 +1641,8 @@ public define HTML_Off_Form span(Int i) public define HTML_Off_Form span(List(CoreAttrs) attrs, String s) = html_tag("span", attrs, [text(s)]). public define HTML_Off_Form span(CoreAttrs attr, String s) = html_tag("span", [attr],[text(s)]). public define HTML_Off_Form span(String s) = html_tag("span", [], [text(s)]). +public define HTML_Off_Form span(List(CoreAttrs) attrs) = html_tag("span", attrs, []). +public define HTML_Off_Form span(CoreAttrs attr) = html_tag("span", [attr],[]). // public define HTML_Off_Form strong(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("strong", attrs, content). -- libgit2 0.21.4