diff options
| -rw-r--r-- | README.md | 28 |
1 files changed, 13 insertions, 15 deletions
@@ -1,7 +1,7 @@ -# template +# tpl -This is an extremely simple general-purpose templating tool written in standard -AWK. +`tpl` is an extremely simple general-purpose templating tool written in +POSIX-2024-compliant AWK. To get started, define a list of variables in a file: @@ -34,7 +34,7 @@ command: ./tpl example/vars example/text.tpl -The result will be written to stdout. +The result will be written to `stdout`. ## Specification @@ -43,7 +43,7 @@ will be of little interest to most users. The program may be invoked as follows: - `tpl [variable file] [template file...]` + tpl [variable file] [template file...] The variable file will be parsed, the variables defined within will be substituted for all apperances of corresponding template variables that appear @@ -79,21 +79,20 @@ characters on either side. The following examples are all legal: Lines beginning with the character `#` are ignored. Note that text following `#` is *not* otherwise ignored, so trailing inline comments are not supported. -Variable names may contain any character supported by the version of awk usd to -execute this script except for the `=` character or any of the regular +Variable names may contain any character supported by the version of awk used +to execute this script except for the `=` character or any of the regular expression metacharacters: \ ^ $ . [ ] | ( ) * + ? { } -There is one exception to this rule: Variable values may reference variables -defined earlier in the file, in which case they must use the brace-delimited -variable format described above. Any other use of braces or any other -prohibited character remains illegal. Variable names specified in the template -variable format must reference actual variables previously defined in the file. +Variable values may reference variables defined earlier in the file, in which +case they must use the brace-delimited variable format described above: + + foo = {{ bar }} baz When a value references a previously defined variable, the most recent value of that variable is used. If a variable name appears more than once, the previous -value is overwritten on each occurence; previous assignments are not affected. +value is overwritten on each assignment; previous assignments are not affected. For example, suppose a variable file contained the following lines: @@ -109,5 +108,4 @@ the value of `food` would be `apple`. A template consists of arbitrary text containing zero or more template variables in the brace-delimited format described above. A variable may appear any number of times within a file or a line. A template variable that does not -reference a valid variable defined in the variable file will be -ignored. +reference a valid variable name defined in the variable file will be ignored. |