Francis.Static (Francis v0.2.0)
View SourceUtilities for working with static assets.
This module provides functions to resolve static paths and URLs, including
support for digested assets generated by mix francis.digest.
Summary
Functions
Returns all assets from the manifest.
Checks if an asset exists in the manifest.
Loads the cache manifest from the given path.
Returns the path for the given asset.
Functions
Returns all assets from the manifest.
Examples
iex> Francis.Static.all()
%{
"app.css" => %{
"digest" => "a1b2c3d4",
"digested_path" => "app-a1b2c3d4.css",
"size" => 1024
}
}
Checks if an asset exists in the manifest.
Examples
iex> Francis.Static.exists?("app.css")
true
iex> Francis.Static.exists?("nonexistent.css")
false
Loads the cache manifest from the given path.
Returns {:ok, manifest} on success, {:error, reason} on failure.
Examples
iex> Francis.Static.load_manifest("priv/static/cache_manifest.json")
{:ok, %{"version" => 1, "files" => %{...}}}
iex> Francis.Static.load_manifest("nonexistent.json")
{:error, :enoent}
Returns the path for the given asset.
If a digest manifest is available and the asset is found in it, returns the digested path. Otherwise, returns the original path.
Examples
iex> Francis.Static.static_path("app.css")
"app-a1b2c3d4.css"