AshTypst.PathResolver (ash_typst v0.2.0)

Copy Markdown View Source

Resolves DSL path values to absolute filesystem paths at runtime.

Why

Mix releases relocate priv/ files: in dev they live at <project>/priv/...; in a release at <release>/lib/<app>-<version>/priv/.... A literal relative string baked into a Spark DSL at compile time only works in dev.

Mirroring the idiomatic Plug.Static pattern (from: {:my_app, "priv/static"}), AshTypst accepts either:

  • a String.t() — used verbatim (caller's responsibility to provide a path that resolves correctly in every environment), or
  • a {atom(), String.t()} tuple — resolved at runtime via Application.app_dir/2, which returns the correct absolute path in dev, test, and Mix releases.

Examples

iex> AshTypst.PathResolver.resolve("priv/typst")
"priv/typst"

iex> path = AshTypst.PathResolver.resolve({:ash_typst, "priv/typst"})
iex> String.ends_with?(path, "ash_typst/priv/typst")
true

Summary

Functions

Returns an absolute (or as-given) path string.

Resolves a list of path_spec/0 values.

Types

path_spec()

@type path_spec() :: String.t() | {atom(), String.t()}

Functions

resolve(path)

@spec resolve(path_spec()) :: String.t()

Returns an absolute (or as-given) path string.

resolve_all(paths)

@spec resolve_all([path_spec()]) :: [String.t()]

Resolves a list of path_spec/0 values.