erlydtl_deps.erl 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. %%%-------------------------------------------------------------------
  2. %%% File: erlydtl_deps.erl
  3. %%% @author Roberto Saccon <rsaccon@gmail.com> [http://rsaccon.com]
  4. %%% @author Evan Miller <emmiller@gmail.com>
  5. %%% @copyright 2008 Roberto Saccon, Evan Miller
  6. %%% @doc
  7. %%% ErlyDTL helper module
  8. %%% @end
  9. %%%
  10. %%% The MIT License
  11. %%%
  12. %%% Copyright (c) 2007 Roberto Saccon, Evan Miller
  13. %%%
  14. %%% Permission is hereby granted, free of charge, to any person obtaining a copy
  15. %%% of this software and associated documentation files (the "Software"), to deal
  16. %%% in the Software without restriction, including without limitation the rights
  17. %%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18. %%% copies of the Software, and to permit persons to whom the Software is
  19. %%% furnished to do so, subject to the following conditions:
  20. %%%
  21. %%% The above copyright notice and this permission notice shall be included in
  22. %%% all copies or substantial portions of the Software.
  23. %%%
  24. %%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25. %%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26. %%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  27. %%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  28. %%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  29. %%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  30. %%% THE SOFTWARE.
  31. %%%
  32. %%% @since 2007-12-16 by Roberto Saccon, Evan Miller
  33. %%%-------------------------------------------------------------------
  34. -module(erlydtl_deps).
  35. -author('rsaccon@gmail.com').
  36. -author('emmiller@gmail.com').
  37. %% API
  38. -export([get_base_dir/0, get_base_dir/1]).
  39. %%====================================================================
  40. %% API
  41. %%====================================================================
  42. %% @spec get_base_dir(Module) -> string()
  43. %% @doc Return the application directory for Module. It assumes Module is in
  44. %% a standard OTP layout application in the ebin or src directory.
  45. get_base_dir(Module) ->
  46. {file, Here} = code:is_loaded(Module),
  47. filename:dirname(filename:dirname(Here)).
  48. %% @spec get_base_dir() -> string()
  49. %% @doc Return the application directory for this application. Equivalent to
  50. %% get_base_dir(?MODULE).
  51. get_base_dir() ->
  52. get_base_dir(?MODULE).
  53. %%====================================================================
  54. %% Internal functions
  55. %%====================================================================