diff options
author | nuex <[email protected]> | 2014-02-22 02:40:45 -0500 |
---|---|---|
committer | nuex <[email protected]> | 2014-03-08 19:30:57 -0500 |
commit | dbede76ca6c76dd6be1cf22bacee1fe345631909 (patch) | |
tree | 0d036ece2a13828a87fd512cf99d1da9eb0a3865 /src | |
parent | 011af017567915c32721a4e4ef1bd58e61ad58d8 (diff) | |
download | relx-dbede76ca6c76dd6be1cf22bacee1fe345631909.tar.gz relx-dbede76ca6c76dd6be1cf22bacee1fe345631909.tar.bz2 relx-dbede76ca6c76dd6be1cf22bacee1fe345631909.zip |
assume templates are already compiled, use dtl for files too
Diffstat (limited to 'src')
-rw-r--r-- | src/rlx_prv_assembler.erl | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl index 255e0da..1a24ab6 100644 --- a/src/rlx_prv_assembler.erl +++ b/src/rlx_prv_assembler.erl @@ -646,43 +646,31 @@ ensure_not_exist(RelConfPath) -> end. erl_script(ErtsVsn) -> - render(erl_script, [{erts_vsn, ErtsVsn}]). + render(erl_script_dtl, [{erts_vsn, ErtsVsn}]). bin_file_contents(RelName, RelVsn, ErtsVsn, ErlOpts) -> - render(bin, [{rel_name, RelName}, {rel_vsn, RelVsn}, {erts_vsn, ErtsVsn}, - {erl_opts, ErlOpts}]). + render(bin_dtl, [{rel_name, RelName}, {rel_vsn, RelVsn}, + {erts_vsn, ErtsVsn}, {erl_opts, ErlOpts}]). extended_bin_file_contents(RelName, RelVsn, ErtsVsn, ErlOpts) -> - render(extended_bin, [{rel_name, RelName}, {rel_vsn, RelVsn}, - {erts_vsn, ErtsVsn}, {erl_opts, ErlOpts}]). + render(extended_bin_dtl, [{rel_name, RelName}, {rel_vsn, RelVsn}, + {erts_vsn, ErtsVsn}, {erl_opts, ErlOpts}]). install_upgrade_escript_contents() -> - read_file("install_upgrade_escript"). + render(install_upgrade_escript_dtl). nodetool_contents() -> - read_file("nodetool"). + render(nodetool_dtl). sys_config_file() -> - read_file("sys_config"). + render(sys_config_dtl). vm_args_file(RelName) -> - render(vm_args, [{rel_name, RelName}]). + render(vm_args_dtl, [{rel_name, RelName}]). -render(TemplateName, Data) -> - TemplatePath = template_path(TemplateName), - {ok, Rendered} = case erlydtl:compile(TemplatePath, TemplateName) of - ok -> TemplateName:render(Data); - {ok, Template} -> Template:render(Data) - end, - Rendered. - -template_path(TemplateName) -> - BaseName = string:join([erlang:atom_to_list(TemplateName), ".dtl"]), - filename:join([code:priv_dir(relx), "templates", BaseName]). +render(Template) -> + render(Template, []). -read_file(FileName) -> - {ok, Contents} = file:read_file(file_path(FileName)), - Contents. - -file_path(FileName) -> - filename:join([code:priv_dir(relx), "files", FileName]). +render(Template, Data) -> + {ok, Rendered} = Template:render(Data), + Rendered. |