tim

Consts

localStorage = r"LocalStorage"

Procs

proc precompile(engine: TimEngine; callback: TimCallback = nil; flush = true;
                waitThread = false; browserSyncPort = Port(6502);
                browserSyncDelay = 200; global: JsonNode = newJObject();
                watchoutNotify = true) {.
    ...raises: [OSError, ResourceExhaustedError],
    tags: [ReadDirEffect, WriteDirEffect], forbids: [].}

Precompiles available templates inside layouts and views directories to either static .html or binary .ast.

Enable flush option to delete outdated generated files (enabled by default).

Enable filesystem monitor by compiling with -d:timHotCode flag. You can create a separate thread for precompiling templates (use waitThread to keep the thread alive)

proc render(engine: TimEngine; viewName: string; layoutName = defaultLayout;
            local = newJObject()): string {....raises: [ValueError, KeyError,
    TimError, Exception, JsonError, IOError, OSError, RegexError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Renders a view based on viewName and layoutName. Exposing data to a template is possible using global or local objects.
proc toHtml(name, code: string): string {....raises: [IOError, OSError, ValueError,
    Exception, KeyError, RegexError, JsonError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}

Macros

macro initCommonStorage(x: untyped)
Initializes a common localStorage that can be shared between controllers

Templates

template `&*`(n: untyped): untyped

Compile-time localStorage initializer that helps reusing shareable data.

Once merged it calls %* macro from std/json for converting NimNode to JsonNode