diff --git a/README.md b/README.md index 0f771c0..7f0cd94 100644 --- a/README.md +++ b/README.md @@ -55,11 +55,11 @@ html_t hello_world() // ^^^ functions that return content to be rendered // must return the html_t or char* types - html_t tmp = malloc(128 * sizeof(char)); + html_t tmp; // ^^^ you don't need to free this malloc, // the framework will do it for you. - sprintf(tmp, "%s", "Hello, World!"); + asprintf(&tmp, "%s", "Hello, World!"); // ^^^ this works because html_t expands // to char* @@ -96,7 +96,7 @@ To test the project, run: `tapm run`. Navigating to `http://127.0.0.1:4000` in y ![getting-started-1](https://i.imgur.com/zGWqSow.png) -For a more complex example, view the project in the `example/` folder of the repo! +For more complex examples, view the project in the `examples/` folder of the repo! ## Appendix @@ -129,13 +129,20 @@ html_t html = HTML( ); ``` -### Building from source +...or: -The root level `Makefile` was designed for POSIX-compliant systems — `tapm build` will not work on Windows outside of WSL. - -### Binding a C function to a DOM event - -![binding-a-c-function-to-a-dom-event](https://camo.githubusercontent.com/339f5dbb4a8a9945034f5b1ba5efc7e5e2780a5353361c2fbea52b5ae47c7c4b/68747470733a2f2f692e696d6775722e636f6d2f6c766e6f646e442e676966) +``` +html_t html = HTMLIFY(" \ +
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "error.cml"
-Macros | |
#define | dbg(to_print, formatter) |
Functions | |
void | displayInner (html_t html) |
void | removeInner (html_t html) |
void | removeStaticInner (html_t html) |
void | removeWithClassInner (char *class_name) |
void | removeChildrenOfIdInner (char *id) |
void | insertAtIdInner (html_t html, char *id) |
html_t | parse_html_wrapper (parse_html_args in) |
html_t | parse_html_core (html_t raw_html, marker_t marker) |
EMSCRIPTEN_KEEPALIVE void | display_html (html_t raw_html) |
EMSCRIPTEN_KEEPALIVE void | remove_html (html_t raw_html) |
EMSCRIPTEN_KEEPALIVE void | remove_static_html (html_t raw_html) |
EMSCRIPTEN_KEEPALIVE void | remove_html_with_class (char *class_name) |
EMSCRIPTEN_KEEPALIVE void | display_html_loop (html_t html_formatter, char **elements, int num_elements, bool reverse) |
EMSCRIPTEN_KEEPALIVE html_t | render_html_loop (html_t html_formatter, char **elements, int num_elements, bool reverse) |
EMSCRIPTEN_KEEPALIVE void | remove_html_children_of_id (char *id) |
EMSCRIPTEN_KEEPALIVE void | insert_html_at_id (html_t raw_html, char *id) |
Variables |
A framework to write HTML directly within C and have it call C functions. Users interact with it through the display_html
and remove_html
functions, and the html_t
and HTML
macros in dcw.h.
#define dbg | +EMSCRIPTEN_KEEPALIVE void display_html | ( | -- | to_print, | +html_t | +raw_html | ) | ++ |
A wrapper for parse_html
, and the JS funtion displayInner
.
raw_html | The HTML you want to display. This should be of type html_t or char*. |