如何将多个代码块传递给 Nim 中的模板?

How to pass multiple code blocks to template in Nim?

我想将多个代码块传递到一个模板中,但是一个代码块的语法并没有真正暗示如何做到这一点。甚至支持吗?

支持。示例:

template foo(block1, block2: untyped): untyped =
  block1
  # do something...
  block2

# now the use
foo:
  echo "hello from block 1"
do: # do keyword does the trick
  echo "hello from block 2"