Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
defmodule MyApp.Web.ComponentHelpers do
def component(template, assigns) do
MyApp.Web.ComponentView.render(template, assigns)
end
def component(template, assigns, do: block) do
MyApp.Web.ComponentView.render(template, Keyword.merge(assigns, [do: block]))
end
def c(name, assigns) do
component(template(name), assigns)
end
def c(name, assigns, opts) do
component(template(name), assigns, opts)
end
defp template(name) when is_atom(name) do
"#{name}.html"
end
end
<%= c :tabs do %>
<%= c :tab, name: "All Products" %>
<%= c :tab, name: "Featured" %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.