Last active
September 2, 2017 12:47
-
-
Save jeremyjh/c3762368ddce42a83fa0f1ab060fb9ba to your computer and use it in GitHub Desktop.
bigapp_web.ex defmacro __using__ clause
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
@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