flyx/emerald

Usage in Jester?

Opened this issue · 5 comments

Xe commented

I would like to use Emerald from Jester but I can't seem to figure out how. How would I use this in Jester?

flyx commented

Basic example:

import jester, asyncdispatch, emerald

proc index(content: string) {.html_templ.} =
  html(lang = "en"):
    head:
      title: "Index"
    body:
      put content

routes:
  get "/":
    var
      s = newStringStream()
      templ = newIndex()
    templ.content = "Hello, world!"
    templ.render(s)
    resp s.data

runForever()

This may be useful to add to the documentation. Keeping the issue open to remind me of that.

When trying this example I get the following error:

lib/pure/collections/sets.nim(282, 43) Error: cannot generate VM code for type(s.data[i].key)

nim -v

Nim Compiler Version 0.14.3 (2016-06-25) [MacOSX: amd64]

flyx commented

Works for me with Nim 0.14.2 (current release), but is broken in devel. Seems to be a Nim bug, I will report it there.

flyx commented

Created Nim issue: nim-lang/Nim#4412

No problems so far with

nim --version
Nim Compiler Version 0.15.1 (2016-10-15) [Linux: amd64]
git hash: 2d2b1a9d481bffaecac35e1e52929cea66f69e0e

Works with Jester just fine.