mirror of
https://github.com/sigmasternchen/libparcival
synced 2025-03-15 03:48:55 +00:00
added extends functionality to demo
This commit is contained in:
parent
75800c531d
commit
296f0edecd
4 changed files with 25 additions and 12 deletions
6
Makefile
6
Makefile
|
@ -40,7 +40,7 @@ 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 gen/greeting.tab.c $(A_LIB)
|
||||
demo: demofiles/demo.c gen/demo.tab.c gen/greeting.tab.c gen/layout.tab.c $(A_LIB)
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
gen/demo.tab.c: demofiles/demo.html.templ $(BIN) gen
|
||||
|
@ -51,6 +51,10 @@ gen/greeting.tab.c: demofiles/greeting.templ $(BIN) gen
|
|||
# change dir to set template name
|
||||
cd demofiles && ../$(BIN) greeting.templ > ../$@
|
||||
|
||||
gen/layout.tab.c: demofiles/layout.html.templ $(BIN) gen
|
||||
# change dir to set template name
|
||||
cd demofiles && ../$(BIN) layout.html.templ > ../$@
|
||||
|
||||
clean:
|
||||
rm -f gen/*
|
||||
rm -f obj/*
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
{$ char* title, char** names, size_t no $}
|
||||
|
||||
{# extends("layout.html.templ", title) #}
|
||||
%%
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
{{ "%s", title }}
|
||||
</title>
|
||||
</head>
|
||||
<body>
|
||||
{% for(size_t i = 0; i < no; i++) %}
|
||||
{# render("greeting.templ", names[i]) #}<br />
|
||||
{% end %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
14
demofiles/layout.html.templ
Normal file
14
demofiles/layout.html.templ
Normal file
|
@ -0,0 +1,14 @@
|
|||
{$ char* title $}
|
||||
|
||||
%%
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
{{ "%s", title }}
|
||||
</title>
|
||||
</head>
|
||||
<body>
|
||||
{# child() #}
|
||||
</body>
|
||||
</html>
|
|
@ -161,11 +161,15 @@ mainSection: /* empty */
|
|||
$$ = $1;
|
||||
addNode(&$$, newOutputNode($3));
|
||||
}
|
||||
| mainSection STRUCTURE_BEGIN optionalWhitespaces structureType optionalWhitespaces OPEN_PARENTHESES text CLOSE_PARENTHESES optionalWhitespaces STRUCTURE_END
|
||||
| mainSection STRUCTURE_BEGIN optionalWhitespaces structureType optionalWhitespaces OPEN_PARENTHESES texts CLOSE_PARENTHESES optionalWhitespaces STRUCTURE_END
|
||||
{
|
||||
$$ = $1;
|
||||
switch($4) {
|
||||
case RENDER_NODE:
|
||||
if (strlen($7) == 0) {
|
||||
yyerror("render command needs at least one argument (template name)");
|
||||
YYERROR;
|
||||
}
|
||||
addNode(&$$, newRenderNode($7));
|
||||
break;
|
||||
case CHILD_NODE:
|
||||
|
|
Loading…
Reference in a new issue