[Proposal] EEx: Allow a comment to follow `end`, e.g., <%= end # comment %>

35 views
Skip to first unread message

Richard Michael

unread,
Aug 11, 2020, 7:35:43 AM8/11/20
to elixir-lang-core
In complex EEx templates I find it helpful to document the end of control-flow or loop statements.  For example:

<% if cond do %>
...long content
<% end # cond %>

Unfortunately, this results in compiler syntax error with "unexpected token: end".

However, EEx does accept "to end of line" style comments with other statements.  For example:

<%= if cond, do: "foo" # a comment %>
<%= "foo" # a comment %>

As workaround I can use:

<% end %><%# if cond %>

Rather clunky, especially since end of line comments compile elsewhere.

Could the EEx compiler be enhanced to accept a comment following `end` ?

This seems not too complicated, I am happy to work on it with a bit of guidance.

(Apologies if I have simply made a mistake or overlooked EEx usage.)

Regards,
Richard

Bruce Tate

unread,
Aug 11, 2020, 8:25:22 AM8/11/20
to elixir-l...@googlegroups.com
I would use it if such a feature were included. 

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/6ce4148a-cca3-461c-890c-d04f21add4a0n%40googlegroups.com.


--

Regards,
Bruce Tate
CEO

José Valim

unread,
Aug 11, 2020, 8:27:47 AM8/11/20
to elixir-l...@googlegroups.com
Please open up an issue and also feel free to submit a pull request. :)

Christopher Keele

unread,
Aug 11, 2020, 5:09:41 PM8/11/20
to elixir-lang-core
I would use this as well! I opened an issue with repro steps: https://github.com/elixir-lang/elixir/issues/10256
Reply all
Reply to author
Forward
0 new messages