Elixir 在exrm版本中加载文件

Elixir 在exrm版本中加载文件,elixir,exrm,Elixir,Exrm,我使用一个html文件作为模板,使用以下代码,在开发模式下工作(不是在exrm版本中): 当版本与exrm打包时,此相对路径不再有效,并且找不到该文件。有没有更好的方法来声明路径,以便在将其转换为发行版时不会弄乱它?使用path.join(“{:code.priv\u dir(:your\u app\u name)}”,“static/templates/receipt\u template.html”)获得正确的路径。我建议始终使用它,因为它保证在任何环境下都能工作 {:ok, templat

我使用一个html文件作为模板,使用以下代码,在开发模式下工作(不是在exrm版本中):

当版本与exrm打包时,此相对路径不再有效,并且找不到该文件。有没有更好的方法来声明路径,以便在将其转换为发行版时不会弄乱它?

使用
path.join(“{:code.priv\u dir(:your\u app\u name)}”,“static/templates/receipt\u template.html”)
获得正确的路径。我建议始终使用它,因为它保证在任何环境下都能工作

{:ok, template} = File.read "priv/static/templates/receipt_template.html"