loics2

loics2

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?

Marked As Solved

steffend

steffend

Phoenix Core Team

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.

Also Liked

josevalim

josevalim

Creator of Elixir

We are discussing ways to disable this per template…

garrison

garrison

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?

LostKobrakai

LostKobrakai

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

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New

Other popular topics Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44265 214
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement