sloane.sh/lib/sloane_sh/asset.ex

27 lines
808 B
Elixir
Raw Normal View History

2024-02-24 13:16:56 -05:00
defmodule SloaneSH.Asset do
use TypedStruct
alias SloaneSH.Config
alias SloaneSH.Context
typedstruct do
field :mod, module(), enforce: true
field :src, String.t(), enforce: true
field :src_contents, binary(), enforce: true
field :attrs, map(), enforce: true
end
@callback extensions(cfg :: Config.t()) :: [String.t()]
@callback attrs(cfg :: Config.t(), path :: String.t(), data :: binary()) ::
2024-02-24 21:11:19 -05:00
{:ok, map(), without_attrs :: term()} | {:ok, map()} | :error | {:error, term()}
2024-02-24 13:16:56 -05:00
@callback render(
cfg :: Config.t(),
ctx :: Context.t(),
path :: String.t(),
data :: binary(),
attrs :: map()
) ::
{:ok, [{dest :: String.t(), binary()}]} | :error | {:error, term()}
end