=== modified file 'README' --- README 2013-09-30 20:33:20 +0000 +++ README 2013-09-30 16:31:33 +0000 @@ -21,133 +21,16 @@ special command to affect how the code is generated. user-defined macros should be possible -@@ - escape for above syntax, prints text out with one at prepended - ... {% %} ... similar to | but works as a block, doesn't have to happen at column 0 -... {{}} ... +...{{ }}... inserts awk expression into the print command. Eg. a variable or result of computation -Unimplemented: - -... {} ... -... {} ... - handling similar to jinja2. pass string to user-defined function, possibly - define more functions to process it afterwards - -... {@macro@} ... - maybe? or perhaps just {% @macro %} to avoid yet another syntax - -... {##} ... - -Implemented macros: - -@include - Macro to recursively parse another template - -@awk - Macro to insert another file as verbatim code - -@text - Macro to insert another file as text - -Implemented macros via external postprocesor: - -@for in -@for var -@endfor - helper for data.awk loops - -Unimplemented macros: - -@function - set function to process {<...>} with - -@out -@out > -@out - make the output be printed to stdout, specific file, or appended to a - variable respectively - -@filter -@macro -@call -@autoescape - like in jinja2 - ---------------------------------------------------------------------------- - -data.awk; simple library for structured data, suitable for input for template -scripts. - -Syntax for data specification: - -= - simple string value. If following line starts with tab, it's considered as - continuation of the value, similarly to MIME headers (but the newline is - preserved) - -=[ -... -... -... -] - field list. Simple table with named columns delimited by tab characters - -currently allowed variable name regex is: /[a-zA-Z_][a-zA-Z0-9_]*/ - -Functions for accessing data: - -loop_start(, ) -> -loop_iter(depth) -loop_end() - iterate through field list of given name, make value for each filed - accessible with given prefix. Loops can be nested, loop_end() ends the - innermost one. Special field names are also exposed: - - _index - the current iteration number, counted from 1 - - _index0 - the current iteration number, counted from 0 - - _revindex - number of iterations till the end of the loop, ending at 1 - - _revindex0 - number of iterations till the end of the loop, ending at 0 - - _first - 1 if on first item, 0 otherwise - - _last - 1 if on last item, 0 otherwise - - _length - number of items in the field list that is being iterated through - -get() -> - returns the value of given variable, taking into account current loop state - -query() -> value - (unimplemeted) query syntax suitable for {<...>} usage. - - EBNF for query syntax: - query = name | "'" expression "'" | "<" query ">" - where: - name is any permissible variable name - expression is awk expression - - nested expressions allow indirection, eg.: the_shop would resolve - to get("the_" get("cheese") "shop") while awk expression allow more - flexible queries at expense of slightly more verbose syntax - ---------------------------------------------------------------------------- - -old readme +... TBD + +-- old readme -- Awk to Awk Templates; compiles interleaved awk and text into pure posix awk code.