-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elixir Language Templating Commenting #57
Comments
what's your major-mode? web-mode? |
It's because web-mode does NOT define the comment operation for this language, a workaround: (defalias 'web-mode-comment-elixir-block 'web-mode-comment-erb-block)
(defalias 'web-mode-uncomment-elixir-block 'web-mode-uncomment-erb-block) You suggestion is interesting, let me think how to do it. For now, I just notify the user which function web-mode not implemented yet. |
@redguardtoo the problem is that elixir and EEx doesn't have any built-in block comments like ruby as most documentation is done via module attributes. Also, there are three types of tags: Tags
EEx.SmartEngine supports the following tags:
<% Elixir expression - inline with output %>
<%= Elixir expression - replace with result %>
<%% EEx quotation - returns the contents inside %>
<%# Comments - they are discarded from source %> This means implementing comments is not easy as you have to keep in memory what the previous type the tag was in before turning them into comments. An alternative would be to wrap the whole line within a comment tag and remove them later when need. Sort of like a paredit slurp and barf. This might be easier as you could probably borrow some code from smartparens or paredit etc. However, I am not sure whether this would affect the compiler in anyway and whether it would escape the templates within comments etc. I am not sure whether the elixir-vim or sublime text modules support commenting, maybe you can take a look at their source if they do. |
can you send me a a complete eex file? for the workaround, defalias to the ruby should work in all three cases. This had better be resolved in web-mode, I could send a pull request to web-mode. Just double check, is below code valid: <%# Elixir expression - inline with output %>
<%#= Elixir expression - replace with result %>
<%#% EEx quotation - returns the contents inside %> |
@redguardtoo the code snippet in the first post is a complete eex file. It is merged and compiled at runtime into a complete html file. |
@redguardtoo the |
I can see that, I will fix that this weekend |
Thanks! |
770981c can comment/uncomment mixed code in web-mode (Chen Bin) v2.2 |
@redguardtoo thanks a ton! :D |
@redguardtoo this fails for nested comments, e.g.: <script src="<%= static_path(@conn, "/js/en.js") %>"></script> Commenting the above gives the following: <!-- <script src="<%= static_path(@conn, "/js/en.js") %>"></script> --> The templating language in question is language agnostic i.e. it doesn't care whether you are using HTML, or YAML or JSON etc. it just does the templating. |
Just double check, so you want to only comment out the template language but keep the html, right? |
@redguardtoo actually, both. I am using |
got, interesting. I will see what I can do. |
upgrade to v2.3 then, (setq evilnc-comment-both-snippet-html t) |
@redguardtoo by the way, it fails for tags that span multilines e.g. <h2>Edit trade</h2>
<%= render "form.html", changeset: @changeset,
action: trade_path(@conn, :update, @trade) %>
|
@redguardtoo and it also fails for multiple tags on one line e.g. <li><%= humanize(attr) %> <%= message %></li>
|
single line is fine, you need for the multiple line tag, I think it's doable but need more complicated algorithm. For now, even web-mode's own command |
@redguardtoo the single line fails when there's multiple EEx tags in-between the html tags |
Could you give me a sample file with multi-line and single line eex, and exact steps to reproduce the issue. and |
@redguardtoo I am on 2.3 and the following is the example that fails: <li><%= humanize(attr) %> <%= message %></li>
|
For multi-line snippet, the best way is do it in web-mode. I will raise a issue to web-mode developer. (fxbois/web-mode#670) For single line, it works on my computer, could you re-install evil-nerd-commenter?
|
When something like this:
is commented, you get this:
However, it doesn't actually comment out the templating tags as they have to be turned to the
<%# %>
form. One suggestion would be to keep the existing html style formatting as it helps the editor display things properly.The text was updated successfully, but these errors were encountered: