Closed elquimista closed 6 years ago
@artificis This is expected behavior. Since the line starts with a Ruby identifier (=
), the rest of the line needs to be interpreted as though it's Ruby. GitHub's highlighter doesn't apply any classes to these attributes, strangely:
<span class="pl-sre"> f.text_area :body, class: 'form-control', placeholder: 'Type a message here'</span>
@tshedor Thanks for responding. So then I guess I'd better open a ticket on ruby tmbundle repo?
You could; I would specify that you're only targeting embedded ruby, because they'll push back since the class
keyword should be highlighted in common patterns like this:
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
It doesn't have to be restricted to embedded ruby. Just need to distinguish between class
and class:
(or :class
).
Ah class
as an attribute. This is still highlighted because it's a reserved keyword, and they're not going to want to include support for libraries in the main Ruby package.
I'm reluctant to target class
like that in this repo because it would target a very specific argument of a specific framework and could have unintended consequences for other apps using Slim but not Rails. (e.g. a teacher addressing her class; a Hash that includes sorting by social strata; a list of high school reunions)
I am sorry, I don't get your point. All I want is just highlight "class" as a keyword when used without trailing/preceding colon and do not highlight otherwise.
So in this instance you want class
highlighted as a symbol when it's used as a symbol. This is inspired by the Rails form helper and most other Rails helpers when class
is treated as a normal attribute and not a keyword:
<textarea class="form-control" placeholder="Type...
However, Slim is found in projects that do not use Rails and may not abide by the same rules. An app, albeit a poorly written one, could have this API:
= inject_label_from_class class: User, method: "displayName"
Here, the current highlighting works because class
is an actual Ruby class.
Or perhaps you're iterating over past high school reunions for your school district:
ruby:
classes = [
{
organizer: 'Suzy',
class: 2010
},
{
organizer: 'Steve',
class: 2011
},
...
]
Applying an override in the Slim repo would force class
here to be treated as an HTML attribute (or constant.other.symbol.ruby
). It's still highlighted as a reserved word, but this is predictable and explainable. Having the highlighter handle all instances of class:
the same regardless of context would not be as expected.
Does that make sense?
GitHub renders
class
hash key just like other keys (placeholder
). But my ST3 renders it as ruby keyword, thus different color from other keys: