diff options
Diffstat (limited to 'xs_html.h')
| -rw-r--r-- | xs_html.h | 19 |
1 files changed, 13 insertions, 6 deletions
| @@ -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; |