diff options
author | technicallyagd <43739261+technicallyagd@users.noreply.github.com> | 2018-10-17 18:51:51 +0800 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-10-17 12:51:51 +0200 |
commit | 88adf775691411a526c18d82b1e6bd83b653f343 (patch) | |
tree | a6d7900bf6cf8fb3cb05dd4e12bc45a7a4c70929 /doc | |
parent | dc72cf7564a66236559e53f10f6acc153d15aa40 (diff) | |
download | Nim-88adf775691411a526c18d82b1e6bd83b653f343.tar.gz |
Elaborate on source code filter usage in the documentation. (#9407)
* Elaborate on source code filter usage. Also gives it an abbreviation, SCF. * Fix the code block formatting * Trim off the unintended usage with import.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/filters.rst | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/doc/filters.rst b/doc/filters.rst index 1937b187c..e8106749e 100644 --- a/doc/filters.rst +++ b/doc/filters.rst @@ -4,7 +4,7 @@ Source Code Filters .. contents:: -A `Source Code Filter` transforms the input character stream to an in-memory +A `Source Code Filter (SCF)` transforms the input character stream to an in-memory output stream before parsing. A filter can be used to provide templating systems or preprocessors. @@ -23,10 +23,23 @@ just like an ordinary procedure call with named or positional arguments. The available parameters depend on the invoked filter. Before version 0.12.0 of the language ``#!`` was used instead of ``#?``. -**Hint:** With ``--hint[codeBegin]:on```or ``--verbosity:2`` -(or higher) Nim lists the processed code after each filter -application. +**Hint:** With ``--hint[codeBegin]:on`` or ``--verbosity:2`` +(or higher) while compiling or `nim check`, Nim lists the processed code after +each filter application. +Usage +===== + +First, put your SCF code in a separate file with filters specified in the first line. +**Note:** You can name your SCF file with any file extension you want, but the conventional extension is ``.tmpl``. + +If we use `generateXML` code shown above and call the SCF file `xmlGen.tmpl` +In your `main.nim`: + +.. code-block:: nim + include "xmlGen.tmpl" + + echo generateXML("John Smith","42") Pipe operator ============= |