=== modified file 'bin/aat.awk' --- bin/aat.awk 2013-09-16 23:15:18 +0000 +++ bin/aat.awk 2013-09-16 21:20:41 +0000 @@ -36,6 +36,7 @@ # Macro to insert another file as verbatim code else if(name == "awk"){ + filename=substr(line, 6) tok_type=T_AWK while(getline 0; i--) { - prefix = loop_stack[i, "pre"] - if(prefix) - if(substr(varname, 1, length(prefix)) != prefix) - continue - loopvar = loop_stack[i, "var"] - looprow = loop_stack[i, "row"] - if(varname == prefix"_index") - return looprow - if(varname == prefix"_index0") - return looprow - 1 - if(varname == prefix"_revindex") - return V[loopvar, "rows"] - looprow + 1 - if(varname == prefix"_revindex0") - return V[loopvar, "rows"] - looprow - if(varname == prefix"_first") - return looprow == 1 - if(varname == prefix"_last") - return looprow == V[loopvar, "rows"] - if(varname == prefix"_length") - return V[loopvar, "rows"] - split(V[loopvar, "fields"], names) + split(V[loop_stack[i, "var"], "fields"], names) for(n in names) { - if(varname == (prefix names[n])) { - split(V[loopvar, looprow], values) + if(varname == (loop_stack[i, "pre"] names[n])) { + split(V[loop_stack[i, "var"], loop_stack[i, "row"]], values) return values[n] } } } - if(DEBUG) { - if(!(varname in V)) { - print "variable not found: " varname >"/dev/stderr" - } - } return V[varname] } === modified file 'hello3.aat' --- hello3.aat 2013-09-16 23:15:18 +0000 +++ hello3.aat 2013-09-16 21:20:41 +0000 @@ -1,15 +1,9 @@ +|!/bin/awk -f @awk data.awk |END { -@for x in spam -{{get("x.name")}} - {{get("x.value")}} -@ for y in spam -{{ get("x.eggs") + get("y.eggs") }} +@ for name in names +Hello {{get("name_v")}}{{get("name__last") ? "!" : ","}} @ endfor -@endfor --------------------- -@for n in names -Hello {{get("n.name") (get("n._last") ? "!" : ",")}} -@endfor Welcome to the world of {{toupper("awk")}} templating! |}