linguist
linguist copied to clipboard
Wrong language detected for .erb templates
.erb
is not HTML! It can be anything.
In my case I have a deployment.yml.erb
and Dockerfile.erb
and thy are both reported as HTML... wrong.
You should report it as Ruby (or, otherwise, as yml + docker in this case).
Note: This report is about the "Languages" info reported near the repository on Github.
The .erb
files are handled in a few different ways depending on what comes immediately before the .erb
, if anything. They may also be grouped with a higher level language which is what appears in the sidebar or primary language of a repo.
For example, .js.erb
is identified as "JavaScript+ERB" and grouped with JavaScript:
https://github.com/github/linguist/blob/e2f638d17598e84f6f91c2d03c2f3e27f22a2163/lib/linguist/languages.yml#L2877-L2883
.axs.erb
and .axi.erb
are identified as "Netlinx+ERB" and not grouped with a higher level language:
https://github.com/github/linguist/blob/e2f638d17598e84f6f91c2d03c2f3e27f22a2163/lib/linguist/languages.yml#L3862-L3867
Whilst .erb
on its own is identified as "HTML+ERB" and grouped under HTML:
https://github.com/github/linguist/blob/e2f638d17598e84f6f91c2d03c2f3e27f22a2163/lib/linguist/languages.yml#L2319-L2331
This is your case because Linguist doesn't have .yml.erb
or Docerkfile.erb
associated with any other languages so it falls back to the original .erb
entry.
.erb
is not HTML! It can be anything.
.erb
files have been identified as "HTML+ERB" on GitHub for well over 9 year as I believe it was the original HTML templating introduced by Rails as RHTML and has since evolved and become used for files written primarily in other languages with Linguist constantly playing catch-up as has been the case with the two examples I've listed.
You should report it as Ruby (or, otherwise, as yml + docker in this case).
I don't think identifying as "Ruby" is the correct approach but certainly think we can extend Linguist to identify your two cases. If in-the-wild usage of .yml.erb
and Dockerfile.erb
meets our minimum usage requirements, please feel free to submit a PR to add them to the respective languages. Details can be found in CONTRIBUTING.md.
Until then, you'll need to use an override to force your preferred language for those files.
Yes, then I think that YML+ERB
and Dockerfile+ERB
would be useful additions. In particular .yml.erb
is very common.