-
-
Save kana-sama/491ae1bd75974797d2bcb43c7489abf9 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