commit 6125bd6174efea22606903d0ca4ae21c3b07fd2a from: Omar Polo date: Thu Sep 29 09:44:24 2022 UTC template: allow '|' in some contexts commit - c590d32c3b82e304a46bdac1512349fdd267dce4 commit + 6125bd6174efea22606903d0ca4ae21c3b07fd2a blob - f3e96dbd4607647561536b0725e2f933bc49400b blob + 59af6214db163cc35a3bb10488b755a2361085a3 --- template/parse.y +++ template/parse.y @@ -88,6 +88,7 @@ typedef struct { %token RENDER TQFOREACH UNSAFE URLESCAPE %token STRING %type string +%type stringy %% @@ -223,8 +224,9 @@ printfargs : /* empty */ printf(" %s", $2); free($2); } + ; -if : '{' IF string '}' { +if : '{' IF stringy '}' { dbg(); printf("if (%s) {\n", $3); free($3); @@ -236,7 +238,7 @@ endif : end | elsif body endif ; -elsif : '{' ELSE IF string '}' { +elsif : '{' ELSE IF stringy '}' { dbg(); printf("} else if (%s) {\n", $4); free($4); @@ -276,6 +278,20 @@ string : STRING string { free($2); } | STRING + ; + +stringy : STRING + | STRING stringy { + if (asprintf(&$$, "%s %s", $1, $2) == -1) + err(1, "asprintf"); + free($1); + free($2); + } + | '|' stringy { + if (asprintf(&$$, "|%s", $2) == -1) + err(1, "asprintf"); + free($2); + } ; %%