templar.core

->function-id

(->function-id ns-name func-name)
Converts the namespace ns-name (string or kw) and function name
func-name (string or kw) to a normalized function id.
Ex. (->function-id :this.that :foobar) => this.that/foobar

apply-template-function

(apply-template-function id fn & args)
Applies the template function resolved for `fn` (string or keyword) for template
with id `id` and optional variadic functions `args`.

cache-function!

(cache-function! ns-name func-name f)
Caches the function f given the namespace ns-name (string or kw) and
the function name func-name (string or kw).

check-function-cache

(check-function-cache ns-name func-name)
Checks the function cache for cached function value given
the namespace ns-name (string or kw) and function name func-name (string or kw).
Returns nil if not found.
Otherwise returns cached function.

clear-function-cache!

(clear-function-cache!)
Clears the function cache.

compliant

(compliant ns template-id)
Determines if namespace `ns` (string or keyword) is compliant with the
template with id `template-id`.
Returns `nil` if compliant.  If not compliant, returns a vector of non-compliant
map messages.

fail

(fail try-r)
Extracts the fail response from a try apply result `try-r`.

fail?

(fail? try-r)
Determines if try apply result `try-r` failed.

function-cache

Cache of resolved/reified functions.

lookup

(lookup id)(lookup id opt)
Lookup given template id `id` and optional `opt`.

namespace-meta-of

(namespace-meta-of id)
Returns the metadata (if present) for namespace associate with template `id`.

namespace-of

(namespace-of id)
Returns the namespace (if present) associate/registered to template with id `id`.

namespace-template-registry

(namespace-template-registry)
Returns the namespace template registry atom @namespaces.

namespaces

Namespaces registry that associates namespaces to templates.

register!

(register! id t)(register! id t meta)
Register template `t` with template id `id` and optional metadata map `meta`.

register-namespace!

(register-namespace! ns id)(register-namespace! ns id meta)
Registers a namespace `ns` (string or keyword) to template with id `id`
and an optional metadata map `meta` for the namespace association.

registered-namespace

(registered-namespace id)
Returns the namespace map entry (if present) associated/registered to template
with id `id`.

registry

Template registry

resolve-function

(resolve-function ns-name func-name & [cache?])
Resolves and returns (if successful) function with namespace ns-name (string or kw)
function name func-name (string or kw) and optional cache? flag to involve
resolved function caching (for performance).
Returns nil if function was not retrieved from cache and/or not resolved/reified.
Otherwise returns the resolved and reified function.

safe-apply

(safe-apply f args)
Wraps a function f call with args (seq) with a try-catch.
Returns nil on thrown exception from f call.
Otherwise returns result of (apply f args).

safe-require

(safe-require ns)
Wraps a namespace require call in try-catch.
Returns nil if namespace successfully resolved and required.
Otherwise, returns string with thrown exception message.

state

(state)
Generates the state of the registered templates.

state-of

(state-of id)
Generates the state of the template with id `id` with associated
namespaces and other state information.

success

(success try-r)
Extracts the successful response from a try apply result `try-r`.

success?

(success? try-r)
Determines if try apply result `try-r` succeeded.

template

(template id)(template id opt)
Retrieve template with id `id` and optional `opt` if not found.

template-registry

(template-registry)
Returns the template registry atom @registry.

try-apply-template-function

(try-apply-template-function id fn & args)
Applies the template function resolved for `fn` (string or keyword) for template
with id `id` and optional variadic functions `args`.

unregister!

(unregister! id)
Unregisters template with id `id`.