Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy context resolver #133

Closed
wants to merge 7 commits into from
Closed

Lazy context resolver #133

wants to merge 7 commits into from

Conversation

barkerja
Copy link
Contributor

@barkerja barkerja commented Apr 19, 2024

Added support to lazily resolve an assign.

Example:

assigns = %{
  "key" => "value",
  "expensive_key" -> fn _data -> {:ok, "value"} end
}

Solid.parse!("{{ key }} — {{ expensive_key }}") |> Solid.render!(assigns) |> IO.iodata_to_binary()
# => "value — value"

The resolver function must accept a single value, the parent context, and return {:ok, any()} to be used to resolve the assign. Any other return signature will be treated as not existing.

@barkerja barkerja closed this Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants