commit - f9a4feb61d225e9b02d58e2d115ba0bd09176b08
commit + 3594b24d3ecf14b835c9de7da858dda4358aef86
blob - 3077f08088a85de54324db2cd16bf37f9c1b867c
blob + 360477fbf519602a7c110f04f6b412fd451bca69
--- 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