-
-
Save abhihooq/f2262ad1d3a81b986d720438bc27e6f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= 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