From 24712fdc3a51ea6e5c5dcc72265f3ffbd19f6767 Mon Sep 17 00:00:00 2001 From: overflowerror Date: Fri, 21 May 2021 21:53:34 +0200 Subject: [PATCH] added demo --- Makefile | 7 +++++++ demofiles/demo.c | 15 +++++++++++++++ demofiles/demo.html.templ | 16 ++++++++++++++++ src/main.c | 1 + 4 files changed, 39 insertions(+) create mode 100644 demofiles/demo.c create mode 100644 demofiles/demo.html.templ diff --git a/Makefile b/Makefile index 6514ba8..6823b2b 100644 --- a/Makefile +++ b/Makefile @@ -40,9 +40,16 @@ gen/lex.yy.c: src/scanner.l gen/y.tab.h gen $(LEX) $< mv lex.yy.c gen/ +demo: demofiles/demo.c gen/demo.tab.c $(A_LIB) + $(CC) $(CFLAGS) -o $@ $^ + +gen/demo.tab.c: demofiles/demo.html.templ $(BIN) gen + # change dir to set template name + cd demofiles && ../$(BIN) demo.html.templ > ../$@ clean: rm -f gen/* rm -f obj/* rm -f $(BIN) rm -f $(A_LIB) + rm -f demo diff --git a/demofiles/demo.c b/demofiles/demo.c new file mode 100644 index 0000000..5ba8cb9 --- /dev/null +++ b/demofiles/demo.c @@ -0,0 +1,15 @@ +#include + +#include + +int main() { + char *names[] = { + "foo", + "bar", + "foobar" + }; + + findTemplate("demo.html.templ")(stdout, "User-List", names, 3); + + return 0; +} diff --git a/demofiles/demo.html.templ b/demofiles/demo.html.templ new file mode 100644 index 0000000..3cd017f --- /dev/null +++ b/demofiles/demo.html.templ @@ -0,0 +1,16 @@ +{$ char* title, char** names, size_t no $} + +%% + + + + + {{ "%s", title }} + + + + {% for(size_t i = 0; i < no; i++) %} + {{ "%s", names[i] }}
+ {% end %} + + diff --git a/src/main.c b/src/main.c index f6901f5..2c371c3 100644 --- a/src/main.c +++ b/src/main.c @@ -20,6 +20,7 @@ const char* filename; void generateHeader() { fprintf(output, "#include \n"); + fprintf(output, "#include \n"); fprintf(output, "#include \n"); fprintf(output, "\n"); fprintf(output, "#include \n");