9struct cwist_html_component {
24 if (!name || !*name || !render_fn)
return NULL;
28 if (!comp)
return NULL;
35 comp->render_fn = render_fn;
56 return comp ? comp->name : NULL;
75 if (!children && child_count > 0)
return NULL;
78 for (
size_t i = 0; i < child_count; i++) {
83 return comp->render_fn(props, children, child_count);
Memory allocation wrappers backed by libttak.
void cwist_free(void *ptr)
Free memory obtained via cwist_alloc/cwist_strdup/etc.
char * cwist_strdup(const char *src)
Duplicate a string using libttak-backed storage.
void * cwist_alloc(size_t size)
Allocate zeroed memory tracked by libttak.
void cwist_html_element_destroy(cwist_html_element_t *el)
Destroy an HTML element and its children.
void cwist_html_component_destroy(cwist_html_component_t *comp)
Destroy a component and free its name.
cwist_html_component_t * cwist_html_component_create(const char *name, cwist_html_component_render_fn render_fn)
Create a named component wrapping a render function.
cwist_html_element_t * cwist_html_component_instantiate(cwist_html_component_t *comp, const void *props, cwist_html_element_t **children, size_t child_count)
Run the component's render function to produce an element tree.
const char * cwist_html_component_name(const cwist_html_component_t *comp)
Get the component's name.
Reusable render units composed on top of the HTML element builder.
cwist_html_element_t *(* cwist_html_component_render_fn)(const void *props, cwist_html_element_t **children, size_t child_count)
Render callback for a component.
struct cwist_html_component cwist_html_component_t