summaryrefslogtreecommitdiffstats
path: root/source/aparser/template.awk
blob: 20157008354ab7092e055320464434d97da6d7f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# template file handling

function print_template(f, tplname, v,
			LOCAL, i, pat, line)
{
	tplname="templates/"tplname;
	if (numlines(tplname) <= 0) fatal("no template "tplname);
	while ((getline line < tplname) > 0) {
		while ((i = match(line,"@[a-zA-Z_]*@")) != 0) {
			pat=substr(line,i+1,RLENGTH-2);
			if (v[pat] == "") fatal("no value for "pat" in "tplname);
			gsub("@"pat"@", v[pat], line);
		}
		
		xprintf(f, "%s\n", line);
	}
	close(tplname);
}