var n {.inject.} = 1 # makes it visible outside of the template body
Run[This](https://nim-lang.org/docs/manual.html#templates-hygiene-in-templates) should help. Work through the macro- and template-related parts of the manual before trying too much, it saves a lot of time. Tip: post code which compiles. Makes replies more likely.
