mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
Backport from xs.
This commit is contained in:
parent
f1afe4416d
commit
8b3471afb7
3 changed files with 23 additions and 13 deletions
15
html.c
15
html.c
|
@ -999,12 +999,15 @@ static xs_html *html_button(char *clss, char *label, char *hint)
|
||||||
{
|
{
|
||||||
xs *c = xs_fmt("snac-btn-%s", clss);
|
xs *c = xs_fmt("snac-btn-%s", clss);
|
||||||
|
|
||||||
return xs_html_sctag("input",
|
/* use an NULL tag to separate non-css-classed buttons from one another */
|
||||||
xs_html_attr("type", "submit"),
|
return xs_html_tag(NULL,
|
||||||
xs_html_attr("name", "action"),
|
xs_html_sctag("input",
|
||||||
xs_html_attr("class", c),
|
xs_html_attr("type", "submit"),
|
||||||
xs_html_attr("value", label),
|
xs_html_attr("name", "action"),
|
||||||
xs_html_attr("title", hint));
|
xs_html_attr("class", c),
|
||||||
|
xs_html_attr("value", label),
|
||||||
|
xs_html_attr("title", hint)),
|
||||||
|
xs_html_text("\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
19
xs_html.h
19
xs_html.h
|
@ -168,8 +168,11 @@ static xs_html *_xs_html_tag_t(xs_html_type type, char *tag, xs_html *var[])
|
||||||
{
|
{
|
||||||
xs_html *a = XS_HTML_NEW();
|
xs_html *a = XS_HTML_NEW();
|
||||||
|
|
||||||
a->type = type;
|
a->type = type;
|
||||||
a->content = xs_dup(tag);
|
|
||||||
|
/* a tag can be NULL, to be a kind of 'wrapper' */
|
||||||
|
if (tag)
|
||||||
|
a->content = xs_dup(tag);
|
||||||
|
|
||||||
_xs_html_add(a, var);
|
_xs_html_add(a, var);
|
||||||
|
|
||||||
|
@ -197,7 +200,8 @@ void xs_html_render_f(xs_html *h, FILE *f)
|
||||||
switch (h->type) {
|
switch (h->type) {
|
||||||
case XS_HTML_TAG:
|
case XS_HTML_TAG:
|
||||||
case XS_HTML_SCTAG:
|
case XS_HTML_SCTAG:
|
||||||
fprintf(f, "<%s", h->content);
|
if (h->content)
|
||||||
|
fprintf(f, "<%s", h->content);
|
||||||
|
|
||||||
/* render the attributes */
|
/* render the attributes */
|
||||||
st = h->f_attr;
|
st = h->f_attr;
|
||||||
|
@ -209,10 +213,12 @@ void xs_html_render_f(xs_html *h, FILE *f)
|
||||||
|
|
||||||
if (h->type == XS_HTML_SCTAG) {
|
if (h->type == XS_HTML_SCTAG) {
|
||||||
/* self-closing tags should not have subtags */
|
/* self-closing tags should not have subtags */
|
||||||
fprintf(f, "/>\n");
|
if (h->content)
|
||||||
|
fprintf(f, "/>");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(f, ">");
|
if (h->content)
|
||||||
|
fprintf(f, ">");
|
||||||
|
|
||||||
/* render the subtags */
|
/* render the subtags */
|
||||||
st = h->f_tag;
|
st = h->f_tag;
|
||||||
|
@ -222,7 +228,8 @@ void xs_html_render_f(xs_html *h, FILE *f)
|
||||||
st = nst;
|
st = nst;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, "</%s>", h->content);
|
if (h->content)
|
||||||
|
fprintf(f, "</%s>", h->content);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
/* 8994b1ef8501039ec97a388680ee361138e34554 2023-11-27T11:45:06+01:00 */
|
/* b26300d01136fad22ee774d20a7da5b299f30d13 2023-12-03T11:38:09+01:00 */
|
||||||
|
|
Loading…
Reference in a new issue