Nim Weekly bio photo

Nim Weekly

News about Nim.

Github

Projects:

Forum:

Core development:

Generic types in macros, experimental new config system based on NimScript, macros.getImpl to access the implementation of a routine or a constant, Improve performance of readLine by using fgets, parallel now requires --experimental mode, toplevel .closure procs are deprecated, doc of pragmas moved to manual, js time fix, staticExec: redirect stderr to stdout so stderr is returned too, workaround windows findNextFile bug, fixed UTF-16 to UTF-8 conversion in widestrs.nim

Example code for this week:

nimble install emerald

Then the following code prints some html code:

import emerald

proc templ(numItems: int) {.html_templ.} =
  html(lang="en"):
    const myTitle = "Title"
    head:
      title: myTitle
    body:
      if numItems > 0:
        ul:
          var content = "x"
          for i in 1 .. numItems:
            li: content
            content = content & "x"

var
  ss = newStringStream()
  myTempl = newTempl()
myTempl.numItems = 3
myTempl.render(ss)
ss.flush()
echo ss.data