Don’t do this. This introduces a runtime dependency to mix
, which usually is not available, since it is a build tool.
You could have something in your config like this:
config :my_app, Debug,
show_additional_info: Mix.env in [:staging, :dev]
Then your snippet could look like this:
<%= if Application.get_env(:my_app, Debug)[:show_additional_info] do %>
<%= render_debug_info %>
<% end %>
And instead of calling Application.get_env(:my_app, Debug)[:show_additional_info]
, you could introduce a helper function in MyAppWeb.HTML.Helpers
and extend MyAppWeb.view/0
to import it in every view…