简体   繁体   中英

Loading files in exrm release

I'm using an html file as a template with the following code, working in dev mode (not in an exrm release):

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

When the release is packaged with exrm, this relative path is no longer valid and the file can't be found. Is there a better way to declare the path, so that it won't get messed up when this is turned into a release?

Use Path.join("#{:code.priv_dir(:your_app_name)}", "static/templates/receipt_template.html") to get the correct path. I would recommend always using this because it is guaranteed to work regardless of environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM