Skip to content

Instantly share code, notes, and snippets.

@onionhammer
Last active January 1, 2016 23:09
Show Gist options
  • Save onionhammer/8214287 to your computer and use it in GitHub Desktop.
Save onionhammer/8214287 to your computer and use it in GitHub Desktop.
import templates
let NO_PROC = proc(n:var string) = discard
proc master(result: var string, head = NO_PROC, body = NO_PROC, footer = NO_PROC) = tmpl html"""
<head>
${ head(result) }
</head>
<body>
${ body(result) }
$if footer != NO_PROC {
<footer>
${ footer(result) }
</footer>
}
</body>
"""
proc content(result: var string) = tmpl html"""
$for i in 0.. 5 {
<div>test!</div>
}
"""
proc head(result: var string) =
tmpl html"""<title>hi!</title>"""
# Test things
var result = ""
master(
result,
head= head,
body= content
)
echo result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment