tadasajon

tadasajon

Suppose I have a *.heex template file that I am iterating rapidly on and I just want to comment out a chunk of it for a few moments. What is the syntax for this? Most of the approaches I have tried just throw errors.

I have resorted to just creating a new empty file, then deleting the lines I want to comment out entirely, saving them in the new file, then copy-pasting them back in later when I want to uncomment them. This is super-laborious.

Showing Posts 1 to 10

kokolegorille

kokolegorille

Like in any html file?

<!--
commented code
-->
tadasajon

tadasajon OP

When I try using <!-- --> I get this:

== Compilation error in file lib/myapp_web/views/product_view.ex ==
** (Phoenix.LiveView.HTMLTokenizer.ParseError) lib/myapp_web/templates/product/show.html.heex:18:1: expected closing `-->` for comment

Here is the state of the file that gives me that error:

<h1>Show Product</h1>

<ul>

  <li>
    <strong>ProductMaker</strong>
    <%= @maker.email %>
  </li>

  <li>
    <strong>Sheet ID:</strong>
    <%= @product.sheet_id %>
  </li>

<!--
  <li>
    <strong>Product:</strong>
    <%= inspect @product.product %>
  </li>
-->

</ul>
<!--
<span><%= link "Edit", to: Routes.product_path(@conn, :edit, @product) %></span> |
<span><%= link "Back", to: Routes.product_path(@conn, :index) %></span>
-->
kokolegorille

kokolegorille

I’m sorry, I was testing on eex file :sweat:

You might find some tips in this issue…

https://github.com/phoenixframework/phoenix_live_view/issues/1590

tadasajon

tadasajon OP

Thanks. That issue seems to be directly related to my problem. I’m still not crystal clear on how to comment out lines in a *.heex file, though – I asked for some more clarification in the issue.

f0rest8

f0rest8

Did you try <%# commented html code here %>

Just looked at your code, the example I just gave will work until you hit your other %> — woops, thanks for the catch @APB9785.

I’m pretty sure I don’t have this issue in my heex files using the standard html comment syntax. I’ll check later and let you know why/if it works for me.

APB9785

APB9785

Creator of ECSx

The opening <% is fine, it’s the closing %> that will end the comment prematurely.

tadasajon

tadasajon OP

In this example:

<h1>Show Product</h1>
<ul>

  <li>
    <strong>ProductMaker</strong>
    <%= @maker.email %>
  </li>

  <li>
    <strong>Sheet ID:</strong>
    <%= @product.sheet_id %>
  </li>

<%#
  <li>
    <strong>Product:</strong>
    <%= inspect @product.product %>
  </li>
%>

</ul>

<span><%= link "Edit", to: Routes.product_path(@conn, :edit, @product) %></span> |
<span><%= link "Back", to: Routes.product_path(@conn, :index) %></span>

I have tried commenting-out the third list item using the syntax you suggested. I get the following error:

Compilation error in file lib/myapp_web/views/product_view.ex ==
** (Phoenix.LiveView.HTMLTokenizer.ParseError) lib/myapp_web/templates/product/show.html.heex:17:3: unmatched closing tag. Expected </ul> for <ul> at line 2, got: </li>

The problem is that there is a <%= something %> within the section that I want to enclose in the comment, so the ending tag for that something ends up closing the comment.

APB9785

APB9785

Creator of ECSx

Mine work OK too for single and multi lines, but if I add a <%= anything %> to the comment, then I will get the aforementioned compilation error.

f0rest8

f0rest8

Yes, just quickly checked and I can second @tadasajon and @APB9785 that I receive that compilation error when <%= something %> pops up inside the comment.

APB9785

APB9785

Creator of ECSx

Adding {anything} to the comment seems to work fine, though. But that won’t solve the problem, because standalone {anything} doesn’t evaluate.

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews