Skip to content

Instantly share code, notes, and snippets.

@rayman22201
Created October 19, 2018 01:50
Show Gist options
  • Save rayman22201/446fd5498c5028b3f3c0f3c21f11bab5 to your computer and use it in GitHub Desktop.
Save rayman22201/446fd5498c5028b3f3c0f3c21f11bab5 to your computer and use it in GitHub Desktop.
macros as templates fun
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