Created
March 28, 2013 18:59
-
-
Save dvv/5265859 to your computer and use it in GitHub Desktop.
Erlang shortcuts
This file contains 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
code:load_abs(os:getenv("HOME") ++ "/.ebin/user_default"), | |
io:format("You may use r() to recompile the code, t() to recompile templates under priv/templates.~n", []). |
This file contains 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
-module(user_default). | |
-compile(export_all). | |
%% compile and reload sources mentioned in Emakefile | |
r() -> | |
make:all([load]). | |
%% compile and reload erlydtl templates under priv/templates subdirectory | |
t() -> | |
t("priv/templates"). | |
t(Dir) -> | |
{ok, Names} = file:list_dir(Dir), | |
[erlydtl:compile( | |
Dir ++ "/" ++ Name, | |
list_to_atom(filename:basename(Name, ".html") ++ "_view"), | |
[{out_dir, "ebin"}] | |
) || Name <- Names]. | |
%% compose Emakefile | |
emakefile() -> | |
Deps = ["." | filelib:wildcard("deps/*")], | |
Text = [io_lib:format( | |
"{\"~s/src/*\", [debug_info, {outdir, \"~s/ebin\"}, {i, \"~s/src\"}, {i, \"~s/include\"}]}.~n", | |
[Dep, Dep, Dep, Dep]) | |
|| Dep <- Deps], | |
file:write_file("Emakefile", Text). |
Author
dvv
commented
Mar 28, 2013
- ~/.erlang
- compile user_default.erl and place it under ~./ebin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment