Last active
October 18, 2018 09:04
-
-
Save technicallyagd/27e5e51f6f3cc5778f8e873304c57e7a to your computer and use it in GitHub Desktop.
The macro to generate template with SCF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#? stdtmpl | standard | |
# view( | |
# for i in 0..12: | |
# if true == true: | |
<h1>hello world $i</h1> | |
# end if | |
# end for | |
# ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include "viewMacro.nim" | |
include "macrosTemp.tmpl" | |
echo pastes_index_view() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros | |
macro view*(x: untyped): untyped = | |
quote: | |
template pastes_index_view*(): untyped = | |
var result {.inject.} = "" | |
`x` | |
result |
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
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