27 lines
615 B
Nim
27 lines
615 B
Nim
import asyncdispatch, jester, moustachu, os, strutils
|
|
|
|
const
|
|
baseTemplate*: string = staticRead "./templates/layout.mustache"
|
|
indexTemplate*: string = staticRead "./templates/index.mustache"
|
|
|
|
testTemplate*: string = """<p>hi!</p>"""
|
|
|
|
template renderMustache*(title: string, templ: string, ctx: Context): expr =
|
|
var
|
|
layoutCtx = moustachu.newContext()
|
|
|
|
layoutCtx["title"] = title
|
|
layoutCtx["body"] = render(templ, ctx)
|
|
|
|
resp render(baseTemplate, layoutCtx)
|
|
|
|
settings:
|
|
port = 5000.Port
|
|
bindAddr = "0.0.0.0"
|
|
|
|
routes:
|
|
get "/":
|
|
renderMustache("test", testTemplate, newContext())
|
|
|
|
runForever()
|