Skip to content

Instantly share code, notes, and snippets.

@jeremyjh
Last active September 2, 2017 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyjh/c3762368ddce42a83fa0f1ab060fb9ba to your computer and use it in GitHub Desktop.
Save jeremyjh/c3762368ddce42a83fa0f1ab060fb9ba to your computer and use it in GitHub Desktop.
bigapp_web.ex defmacro __using__ clause
@webdir "bigapp_web"
@doc """
When used, dispatch to the appropriate controller/view/etc.
"""
defmacro __using__(:view) do
view_path =
__CALLER__.file
|> String.split(@webdir)
|> List.last
|> Path.dirname
templates = "lib/#{@webdir <> view_path}/templates"
apply(__MODULE__, :view, [[root: templates,
namespace: __CALLER__.module,
pattern: "**/*"]])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment