Packages icon indicating copy to clipboard operation
Packages copied to clipboard

[HTML (Rails)] Ruby in template files (.html.erb) does not highlight function names correctly

Open tslaton opened this issue 4 years ago • 4 comments

  • Sublime Version: 4107 & 4109
  • OS Version: macOS 11.4
<% provide(:title, "Sign up")%>
<h1>Sign up</h1>
<%= form_with(model: @user, local: true) do |f| %>
  <%= render 'shared/error_messages' %>
  <%= f.label :name %>
  <%= f.text_field :name %>
  <%= f.label :email %>
  <%= f.email_field :email %>
  <%= f.label :password %>
  <%= f.password_field :password %>
  <%= f.label :password_confirmation, "Confirmation" %>
  <%= f.password_field :password_confirmation %>
  <%= f.submit "Create account" %>
<% end %>
Screen Shot 2021-06-28 at 10 08 58 PM

I'd expect provide, form_with, label, text_field, email_field, password_field, and submit to have function highlighting like render.

Color scheme shown is the default Mariana.

tslaton avatar Jun 29 '21 05:06 tslaton

While render is scoped as known builtin function in Ruby for Rails syntax, basic Ruby doesn't scope function calls at all. Not sure why it doesn't though.

deathaxe avatar Jun 29 '21 14:06 deathaxe

Another note on this: As title says this issue is for #2797.

The code example completely breaks highlighting of current Ruby on Rails syntax on master.

grafik

deathaxe avatar Jun 29 '21 16:06 deathaxe

  • Sublime Version: 4126
  • Color Scheme: Marina
  • OS Version: macOS 12.4
Captura de Pantalla 2022-08-21 a las 22 47 28

I am working with Rails and the syntax highlight it's confused:

  • for global variables only the @ symbol is highlighted
  • select is highlighted but not label
  • |f| is highlighted but not when it is used in the block

ocarreterom avatar Aug 21 '22 20:08 ocarreterom

Just dealing with your bullet points:

  • This is the color scheme. Variables that are not language constants are specifically made white. The @ is considered punctuation, so it is teal.
  • select is the name of a Ruby built-in function, not just the name of the HTML drop-down element you are trying to make. label doesn't have a special meaning like that.
  • |f| is highlighted like function parameters are in Mariana, which is different from variables in other places.

I think your best start is tweaking your color scheme (or choosing a new one). I like Mariana, but a couple things don't work the way I want, so I do UI: Edit Current Color Scheme in the command palette to tinker with it. The select problem I think you're just going to have to deal with, unless you want to disable select built-in highlighting all over Ruby.

michaelblyons avatar Aug 21 '22 23:08 michaelblyons