No matching definitions.

template/render

src/template/render.tur
defn

render-ast

(render-ast [root : int env : int] :)

render a pre-parsed node chain against env.

rootnode chain head from `parse`
envEnv handle from `env-new`

A heap-allocated cstr. Caller frees with `free`.

(render-ast (parse (lex "<%= x %>")) e)

Since: 0.1.0

defn

render

(render [src : cstr env : int] :)

lex+parse+render-ast a template string against env.

srctemplate source (NUL-terminated cstr)
envEnv handle

A heap-allocated cstr containing the rendered output. Caller frees.

(render "Hello, <%= name %>!" e)

Since: 0.1.0

defn

render-file

(render-file [path : cstr env : int] :)

read `path`, render the template body against env.

pathpath to a template file
envEnv handle

(Result cstr cstr) -- ok payload is a heap cstr that the caller frees; err payload is a static diagnostic.

(let [r (render-file "page.html.tur" e)]
    (if (ok? r) (println (ok-val r)) (println (err-val r))))

Since: 0.2.0

Internal definitions
__read-file-- read a file's contents into a fresh malloc'd cstr (NULL on fail).
__cstr-null?-- true if a cstr is NULL.
__free-cstr-- free a heap cstr (used internally for file buffers).