commit - 83577462cc61708af1c98d70939bb1d6c54a1506
commit + 0f297329190ee2d8862b5e7f5fc3b27b960e4f49
blob - 1bebb961c5e733837754ec787917a8b8d6bdc572
blob + d61bd1fae0e2bab34ea4d6fe34e3f2301879546a
--- template/parse.y
+++ template/parse.y
%}
%token DEFINE ELSE END ERROR FINALLY FOR IF INCLUDE PRINTF
-%token RENDER TQFOREACH UNSAFE URLESCAPE
+%token RENDER TQFOREACH UNSAFE URLESCAPE WHILE
%token <v.string> STRING
%type <v.string> string
%type <v.string> stringy
} body end {
fputs("}\n", fp);
}
+ | '{' WHILE stringy '}' {
+ fprintf(fp, "while (%s) {\n", $3);
+ free($3);
+ } body end {
+ fputs("}\n", fp);
+ }
;
end : '{' END '}'
{ "tailq-foreach", TQFOREACH },
{ "unsafe", UNSAFE },
{ "urlescape", URLESCAPE },
+ { "while", WHILE },
};
const struct keywords *p;
blob - 31b32697b9affdd4231edc3b70f8abaf0bb8300c
blob + 5b286fbc62df91dfd76bf8f751fd3591c532b925
--- template/template.7
+++ template/template.7
Looping construct similar to the C loop.
.It Cm {{ Ic tailq-foreach Ar var head fieldname Cm }} Ar .. Cm {{ Ic end Cm }}
Looping construct similar to the queue.h macro TAILQ_FOREACH.
+.It Cm {{ Ic while Ar ... Cm }} Ar ... Cm {{ Ic end Cm }}
+Looping construct similar to the C while loop.
.It Cm {{ Ar expression Cm | Ic unsafe Cm }}
Output
.Ar expression