我使用html文件作为模板,使用以下代码,在dev模式下工作(不在exrm版本中):
{:ok, template} = File.read "priv/static/templates/receipt_template.html"
Run Code Online (Sandbox Code Playgroud)
当发行版与exrm打包时,此相对路径不再有效,并且找不到该文件.是否有更好的方法来声明路径,以便在将其转换为版本时不会搞砸?
使用Path.join("#{:code.priv_dir(:your_app_name)}", "static/templates/receipt_template.html")以获得正确的路径.我建议总是使用它,因为无论环境如何,它都可以保证工作.