Skip to content

Instantly share code, notes, and snippets.

@onionhammer
Created December 14, 2013 03:58
Show Gist options
  • Save onionhammer/7955521 to your computer and use it in GitHub Desktop.
Save onionhammer/7955521 to your computer and use it in GitHub Desktop.
import macros
# Generate tags
macro make(names: openarray[expr]): stmt {.immediate.} =
result = newStmtList()
for i in 0..names.len - 1:
result.add newProc(
name = ident($names[i]).postfix("*"),
params = [
newIdentNode("string"),
newIdentDefs(newIdentNode("content"),
newIdentNode("string"))
],
body = newStmtList(
parseStmt("content")
)
)
make([
html,
xml,
glsl,
js
])
when isMainModule:
## Test tags
var body = annotate.html"""
<ul>
<li>1
<li>2
</ul>
"""
echo body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment