Clarify use of special : for passing a block of stmts to template (#8133)
Fixes https://github.com/nim-lang/Nim/issues/8131.
This commit is contained in:
parent
722abbe9c9
commit
5ac74da926
1 changed files with 5 additions and 5 deletions
|
|
@ -4966,8 +4966,8 @@ clearer names.
|
||||||
Passing a code block to a template
|
Passing a code block to a template
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
You can pass a block of statements as a last parameter to a template via a
|
You can pass a block of statements as the last argument to a template
|
||||||
special ``:`` syntax:
|
following the special ``:`` syntax:
|
||||||
|
|
||||||
.. code-block:: nim
|
.. code-block:: nim
|
||||||
:test: "nim c $1"
|
:test: "nim c $1"
|
||||||
|
|
@ -4982,11 +4982,11 @@ special ``:`` syntax:
|
||||||
else:
|
else:
|
||||||
quit("cannot open: " & fn)
|
quit("cannot open: " & fn)
|
||||||
|
|
||||||
withFile(txt, "ttempl3.txt", fmWrite):
|
withFile(txt, "ttempl3.txt", fmWrite): # special colon
|
||||||
txt.writeLine("line 1")
|
txt.writeLine("line 1")
|
||||||
txt.writeLine("line 2")
|
txt.writeLine("line 2")
|
||||||
|
|
||||||
In the example the two ``writeLine`` statements are bound to the ``actions``
|
In the example, the two ``writeLine`` statements are bound to the ``actions``
|
||||||
parameter.
|
parameter.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue