Skip to content

Instantly share code, notes, and snippets.

@toland
Created July 13, 2009 20:22
Show Gist options
  • Save toland/146428 to your computer and use it in GitHub Desktop.
Save toland/146428 to your computer and use it in GitHub Desktop.
Use ErlyDTL templates with Nitrogen
-module(my_util).
-compile(export_all).
template_path(Template) ->
filename:join([code:priv_dir(my_app), templates, Template]).
render_template(Name, Variables) ->
Template = template_path(Name ++ ".html"),
Mod = list_to_atom(Name ++ "_template"),
ok = erlydtl:compile(Template, Mod),
{ok, Body} = Mod:render([{flash, element_flash:render()},
{script, wf_script:get_script()} | Variables]),
Body.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment