-
-
Save rayman22201/446fd5498c5028b3f3c0f3c21f11bab5 to your computer and use it in GitHub Desktop.
macros as templates fun
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 render*(body: string) :untyped = | |
return quote do: | |
if (resp.code == 0): | |
resp.code = 200 | |
resp.body = `body` | |
type Response = object | |
code: int | |
body: string | |
var resp = Response(code:0, body:"") | |
render(body="abc") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment