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> as a tagged struct: ok payload is a heap cstr that the caller frees; err payload is a heap cstr diagnostic.

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

Since: 0.1.0

Internal definitions
__read-file-- read a file's contents into a fresh malloc'd cstr (0 on fail).
__free-cstr-- free a heap cstr (used internally for file buffers).
__cstr-from-int-- coerce an :int pointer back to :cstr for render.
__cstr->int-- coerce a :cstr back to :int (heap pointer).
__err-msg-- allocate a heap cstr containing an error message.
__ok-result-- build an ok result wrapping a cstr-pointer payload.
__err-result-- build an err result wrapping a cstr message.