Disable HEEx debug annotations conditionnaly

Hey!

I implemented this code some time ago to compile HEEx templates and give them to MJML (it’s mostly inspired by the live view renderer).

It works great, but recently, I enabled caller annotations in phoenix, and the @ symbol seems to cause some issues with MJML, and it fails to compile.

Is there a way to disable debug anotations just for this? The only place I found a reference to the debug annotations is in here, and it seems to only look at the application configuration.

Does anyone have any ideas?

Yeah, the call site is here but it looks like it’s just based off of the global config.

I guess you could wrap those templates in put_env but that’s obviously insane. Maybe send a proposal or PR?

This is global config because the eex engine usually runs at compile time. So manual put_env calls would not be helpful here.

Oh yeah, forgot about that. Obviously a terrible idea regardless lol.

We are discussing ways to disable this per template…

Nice, it would be great!

In the meantime, it’s easier to strip HTML comments and additional attributes with lazy_html. Not the best solution, but not the worst either

In LiveView 1.2 (no release date yet), you’ll be able to do:

defmodule MyComponentModule do
  use Phoenix.Component

  @debug_heex_annotations false
  @debug_attributes false

  # any HEEx in here won't have debug annotations or data-phx-loc applied
end

Note that any component you call from a different module will still contain the annotations.