aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/erlydtl.mk
diff options
context:
space:
mode:
authorEvgeny M <[email protected]>2014-11-16 22:53:52 +0300
committerevgeny <[email protected]>2015-01-03 14:56:02 +0300
commitba41fb80efcd2083d1cc98802a118d4db2c1eaf8 (patch)
tree00176caefcecdb8ad38c8618a3e1b311f31e07d2 /plugins/erlydtl.mk
parentdf5a4779bc3c5a5bffee4186a8f69408262de5d2 (diff)
downloaderlang.mk-ba41fb80efcd2083d1cc98802a118d4db2c1eaf8.tar.gz
erlang.mk-ba41fb80efcd2083d1cc98802a118d4db2c1eaf8.tar.bz2
erlang.mk-ba41fb80efcd2083d1cc98802a118d4db2c1eaf8.zip
Make it possible to create erlydtl beam files with full path in the name
if DTL_FULL_PATH=1 /templates/a/b/c.dtl -> a_b_c_dtl.beam otherwise (as it was before) -> c_dtl.beam add return_errors flag to erlydtl:compile to return {error, Errors} instead of error; add {doc_root, "templates"} flag to allow extend and include templates from parent directories (by default erlydtl looks for parent template in the directory of the current template); make compilation stop if erlydtl:compile returns an error
Diffstat (limited to 'plugins/erlydtl.mk')
-rw-r--r--plugins/erlydtl.mk12
1 files changed, 9 insertions, 3 deletions
diff --git a/plugins/erlydtl.mk b/plugins/erlydtl.mk
index e288072..8d8795f 100644
--- a/plugins/erlydtl.mk
+++ b/plugins/erlydtl.mk
@@ -1,6 +1,10 @@
# Copyright (c) 2013-2014, Loïc Hoguin <[email protected]>
# This file is part of erlang.mk and subject to the terms of the ISC License.
+# Configuration.
+
+DTL_FULL_PATH ?= 0
+
# Verbosity.
dtl_verbose_0 = @echo " DTL " $(filter %.dtl,$(?F));
@@ -11,9 +15,11 @@ dtl_verbose = $(dtl_verbose_$(V))
define compile_erlydtl
$(dtl_verbose) erl -noshell -pa ebin/ $(DEPS_DIR)/erlydtl/ebin/ -eval ' \
Compile = fun(F) -> \
- Module = list_to_atom( \
- string:to_lower(filename:basename(F, ".dtl")) ++ "_dtl"), \
- erlydtl:compile(F, Module, [{out_dir, "ebin/"}]) \
+ S = fun (1) -> re:replace(filename:rootname(string:sub_string(F, 11), ".dtl"), "/", "_", [{return, list}, global]); \
+ (0) -> filename:basename(F, ".dtl") \
+ end, \
+ Module = list_to_atom(string:to_lower(S($(DTL_FULL_PATH))) ++ "_dtl"), \
+ {ok, _} = erlydtl:compile(F, Module, [{out_dir, "ebin/"}, return_errors, {doc_root, "templates"}]) \
end, \
_ = [Compile(F) || F <- string:tokens("$(1)", " ")], \
init:stop()'