diff options
| -rw-r--r-- | html.c | 15 | ||||
| -rw-r--r-- | xs_html.h | 19 | ||||
| -rw-r--r-- | xs_version.h | 2 |
3 files changed, 23 insertions, 13 deletions
| @@ -999,12 +999,15 @@ static xs_html *html_button(char *clss, char *label, char *hint) | |||
| 999 | { | 999 | { |
| 1000 | xs *c = xs_fmt("snac-btn-%s", clss); | 1000 | xs *c = xs_fmt("snac-btn-%s", clss); |
| 1001 | 1001 | ||
| 1002 | return xs_html_sctag("input", | 1002 | /* use an NULL tag to separate non-css-classed buttons from one another */ |
| 1003 | xs_html_attr("type", "submit"), | 1003 | return xs_html_tag(NULL, |
| 1004 | xs_html_attr("name", "action"), | 1004 | xs_html_sctag("input", |
| 1005 | xs_html_attr("class", c), | 1005 | xs_html_attr("type", "submit"), |
| 1006 | xs_html_attr("value", label), | 1006 | xs_html_attr("name", "action"), |
| 1007 | xs_html_attr("title", hint)); | 1007 | xs_html_attr("class", c), |
| 1008 | xs_html_attr("value", label), | ||
| 1009 | xs_html_attr("title", hint)), | ||
| 1010 | xs_html_text("\n")); | ||
| 1008 | } | 1011 | } |
| 1009 | 1012 | ||
| 1010 | 1013 | ||
| @@ -168,8 +168,11 @@ static xs_html *_xs_html_tag_t(xs_html_type type, char *tag, xs_html *var[]) | |||
| 168 | { | 168 | { |
| 169 | xs_html *a = XS_HTML_NEW(); | 169 | xs_html *a = XS_HTML_NEW(); |
| 170 | 170 | ||
| 171 | a->type = type; | 171 | a->type = type; |
| 172 | a->content = xs_dup(tag); | 172 | |
| 173 | /* a tag can be NULL, to be a kind of 'wrapper' */ | ||
| 174 | if (tag) | ||
| 175 | a->content = xs_dup(tag); | ||
| 173 | 176 | ||
| 174 | _xs_html_add(a, var); | 177 | _xs_html_add(a, var); |
| 175 | 178 | ||
| @@ -197,7 +200,8 @@ void xs_html_render_f(xs_html *h, FILE *f) | |||
| 197 | switch (h->type) { | 200 | switch (h->type) { |
| 198 | case XS_HTML_TAG: | 201 | case XS_HTML_TAG: |
| 199 | case XS_HTML_SCTAG: | 202 | case XS_HTML_SCTAG: |
| 200 | fprintf(f, "<%s", h->content); | 203 | if (h->content) |
| 204 | fprintf(f, "<%s", h->content); | ||
| 201 | 205 | ||
| 202 | /* render the attributes */ | 206 | /* render the attributes */ |
| 203 | st = h->f_attr; | 207 | st = h->f_attr; |
| @@ -209,10 +213,12 @@ void xs_html_render_f(xs_html *h, FILE *f) | |||
| 209 | 213 | ||
| 210 | if (h->type == XS_HTML_SCTAG) { | 214 | if (h->type == XS_HTML_SCTAG) { |
| 211 | /* self-closing tags should not have subtags */ | 215 | /* self-closing tags should not have subtags */ |
| 212 | fprintf(f, "/>\n"); | 216 | if (h->content) |
| 217 | fprintf(f, "/>"); | ||
| 213 | } | 218 | } |
| 214 | else { | 219 | else { |
| 215 | fprintf(f, ">"); | 220 | if (h->content) |
| 221 | fprintf(f, ">"); | ||
| 216 | 222 | ||
| 217 | /* render the subtags */ | 223 | /* render the subtags */ |
| 218 | st = h->f_tag; | 224 | st = h->f_tag; |
| @@ -222,7 +228,8 @@ void xs_html_render_f(xs_html *h, FILE *f) | |||
| 222 | st = nst; | 228 | st = nst; |
| 223 | } | 229 | } |
| 224 | 230 | ||
| 225 | fprintf(f, "</%s>", h->content); | 231 | if (h->content) |
| 232 | fprintf(f, "</%s>", h->content); | ||
| 226 | } | 233 | } |
| 227 | 234 | ||
| 228 | break; | 235 | break; |
diff --git a/xs_version.h b/xs_version.h index 83dfedc..9a2f401 100644 --- a/xs_version.h +++ b/xs_version.h | |||
| @@ -1 +1 @@ | |||
| /* 8994b1ef8501039ec97a388680ee361138e34554 2023-11-27T11:45:06+01:00 */ | /* b26300d01136fad22ee774d20a7da5b299f30d13 2023-12-03T11:38:09+01:00 */ | ||