Can I disable warnings about undefined assigns with EEx.compile_file/2 and Code.eval_quoted/3?

I’m working on doing some external file compilations and am wondering if I can somehow disable warnings about unavailable assigns. Why the heck would I want that?! As I describe what I’m doing hopefully either 1) the answer; or 2) an alternate solution will be obvious to you.

Let’s say I have a file with some pretty simple contents that I run through EEx.compile_file/2:

  hello = :world
  balance = "1 zillion dollars"

<%= @plan_to_end_world_hunger %>

I’d like to take that file and extract those initial bindings (hello and balance). At this point, I don’t care that @plan_to_end_world_hunger assign is unavailable.

Right now I’m doing this by taking the output of EEx.compile_file/2 and running it through Code.eval_quoted/3. Code.eval_quoted/3 returns {content, bindings} and I’m discarding the content for now. I just want the bindings.

But I get warnings that @plan_to_end_world_hunger is unavailable. I found the spot in the EEx code that presents these errors ( and a comment states that the future looks even worse for me: it will soon raise errors instead of just warn.

I experimented with implementing my own EEx engine but the functions that handle assigns (handle_assign/1 and fetch_assign/2) are not part of the defined behaviour and not defoverrideable. The simple solution in my mind is to define them as part of the behaviour. So now I have a local file called EEx.EngineWithNoWarnings that is mostly a copy/paste of EEx.Engine but with those functions changed. I can then potentially pass it as the engine option to EEx.compile_file/2.

Is this my solution? The amount of copy/paste in that makes me a bit uncomfortable. Am I too focused on THIS solution that I’m not seeing an easier solution?

I’d really appreciate your thoughts! Thanks in advance.