Skip to content

Instantly share code, notes, and snippets.

@dvv
Created March 28, 2013 18:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvv/5265859 to your computer and use it in GitHub Desktop.
Save dvv/5265859 to your computer and use it in GitHub Desktop.
Erlang shortcuts
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", []).
-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).
@dvv
Copy link
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