commit 8b3471a
default
·
2023-12-03 10:43:40 +0000 UTC
parent f1afe44
Backport from xs.
3 files changed,
+23,
-13
M
html.c
+9,
-6
1@@ -999,12 +999,15 @@ static xs_html *html_button(char *clss, char *label, char *hint)
2 {
3 xs *c = xs_fmt("snac-btn-%s", clss);
4
5- return xs_html_sctag("input",
6- xs_html_attr("type", "submit"),
7- xs_html_attr("name", "action"),
8- xs_html_attr("class", c),
9- xs_html_attr("value", label),
10- xs_html_attr("title", hint));
11+ /* use an NULL tag to separate non-css-classed buttons from one another */
12+ return xs_html_tag(NULL,
13+ xs_html_sctag("input",
14+ xs_html_attr("type", "submit"),
15+ xs_html_attr("name", "action"),
16+ xs_html_attr("class", c),
17+ xs_html_attr("value", label),
18+ xs_html_attr("title", hint)),
19+ xs_html_text("\n"));
20 }
21
22
+13,
-6
1@@ -168,8 +168,11 @@ static xs_html *_xs_html_tag_t(xs_html_type type, char *tag, xs_html *var[])
2 {
3 xs_html *a = XS_HTML_NEW();
4
5- a->type = type;
6- a->content = xs_dup(tag);
7+ a->type = type;
8+
9+ /* a tag can be NULL, to be a kind of 'wrapper' */
10+ if (tag)
11+ a->content = xs_dup(tag);
12
13 _xs_html_add(a, var);
14
15@@ -197,7 +200,8 @@ void xs_html_render_f(xs_html *h, FILE *f)
16 switch (h->type) {
17 case XS_HTML_TAG:
18 case XS_HTML_SCTAG:
19- fprintf(f, "<%s", h->content);
20+ if (h->content)
21+ fprintf(f, "<%s", h->content);
22
23 /* render the attributes */
24 st = h->f_attr;
25@@ -209,10 +213,12 @@ void xs_html_render_f(xs_html *h, FILE *f)
26
27 if (h->type == XS_HTML_SCTAG) {
28 /* self-closing tags should not have subtags */
29- fprintf(f, "/>\n");
30+ if (h->content)
31+ fprintf(f, "/>");
32 }
33 else {
34- fprintf(f, ">");
35+ if (h->content)
36+ fprintf(f, ">");
37
38 /* render the subtags */
39 st = h->f_tag;
40@@ -222,7 +228,8 @@ void xs_html_render_f(xs_html *h, FILE *f)
41 st = nst;
42 }
43
44- fprintf(f, "</%s>", h->content);
45+ if (h->content)
46+ fprintf(f, "</%s>", h->content);
47 }
48
49 break;
+1,
-1
1@@ -1 +1 @@
2-/* 8994b1ef8501039ec97a388680ee361138e34554 2023-11-27T11:45:06+01:00 */
3+/* b26300d01136fad22ee774d20a7da5b299f30d13 2023-12-03T11:38:09+01:00 */