Rewrote templating engine

This commit is contained in:
joss 2024-11-19 22:51:41 +01:00
parent 63dd5fd5b3
commit 577eba63a0
3 changed files with 29 additions and 7 deletions

22
template.awk Normal file
View file

@ -0,0 +1,22 @@
# escaped lines
/^[ \t]*%/ {
i = index($0, "%");
print substr($0, i+1, length($0)-i);
next;
}
# inline code
/%\(.*%\)/ {
gsub(/'/, "\\'", $0);
gsub(/%\(.*%\)/, "';echo -n &;echo '", $0);
gsub(/%\(/, "", $0);
gsub(/%\)/, "", $0);
printf("echo -n '%s'\n", $0);
next;
}
{
gsub(/'/, "\\'", $0);
printf("echo '%s'\n", $0);
}