Skip to content

Instantly share code, notes, and snippets.

@technicallyagd
Last active October 18, 2018 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technicallyagd/27e5e51f6f3cc5778f8e873304c57e7a to your computer and use it in GitHub Desktop.
Save technicallyagd/27e5e51f6f3cc5778f8e873304c57e7a to your computer and use it in GitHub Desktop.
The macro to generate template with SCF
#? stdtmpl | standard
# view(
# for i in 0..12:
# if true == true:
<h1>hello world $i</h1>
# end if
# end for
# )
include "viewMacro.nim"
include "macrosTemp.tmpl"
echo pastes_index_view()
import macros
macro view*(x: untyped): untyped =
quote:
template pastes_index_view*(): untyped =
var result {.inject.} = ""
`x`
result
@technicallyagd
Copy link
Author

First working version of creating template using macro within SCF file.
Note the two extra spaces before result.add is essential to make indentation correct.

#? stdtmpl(emit="  result.add") | standard

@technicallyagd
Copy link
Author

You can actually use view(code) syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment