mirror of
https://github.com/sigmasternchen/libparcival
synced 2025-03-15 11:58:53 +00:00
added demo
This commit is contained in:
parent
2804ca7c0a
commit
24712fdc3a
4 changed files with 39 additions and 0 deletions
7
Makefile
7
Makefile
|
@ -40,9 +40,16 @@ gen/lex.yy.c: src/scanner.l gen/y.tab.h gen
|
||||||
$(LEX) $<
|
$(LEX) $<
|
||||||
mv lex.yy.c gen/
|
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:
|
clean:
|
||||||
rm -f gen/*
|
rm -f gen/*
|
||||||
rm -f obj/*
|
rm -f obj/*
|
||||||
rm -f $(BIN)
|
rm -f $(BIN)
|
||||||
rm -f $(A_LIB)
|
rm -f $(A_LIB)
|
||||||
|
rm -f demo
|
||||||
|
|
15
demofiles/demo.c
Normal file
15
demofiles/demo.c
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <templates.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
char *names[] = {
|
||||||
|
"foo",
|
||||||
|
"bar",
|
||||||
|
"foobar"
|
||||||
|
};
|
||||||
|
|
||||||
|
findTemplate("demo.html.templ")(stdout, "User-List", names, 3);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
16
demofiles/demo.html.templ
Normal file
16
demofiles/demo.html.templ
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{$ char* title, char** names, size_t no $}
|
||||||
|
|
||||||
|
%%
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>
|
||||||
|
{{ "%s", title }}
|
||||||
|
</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% for(size_t i = 0; i < no; i++) %}
|
||||||
|
{{ "%s", names[i] }}<br />
|
||||||
|
{% end %}
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -20,6 +20,7 @@ const char* filename;
|
||||||
|
|
||||||
void generateHeader() {
|
void generateHeader() {
|
||||||
fprintf(output, "#include <stdio.h>\n");
|
fprintf(output, "#include <stdio.h>\n");
|
||||||
|
fprintf(output, "#include <stdlib.h>\n");
|
||||||
fprintf(output, "#include <stdarg.h>\n");
|
fprintf(output, "#include <stdarg.h>\n");
|
||||||
fprintf(output, "\n");
|
fprintf(output, "\n");
|
||||||
fprintf(output, "#include <templates.h>\n");
|
fprintf(output, "#include <templates.h>\n");
|
||||||
|
|
Loading…
Reference in a new issue