In Rails 2.0 view templates have an ending like .html.erb, .css.erb or .xml.erb (instead of f.i. .rhtml in Rails 1.2.x). So if you've selected a syntax highlighting in TextMate for - say a .html.erb template, this would apply to all templates with ending .erb (i.e. .css.erb etc.) and that's bad, because you want the .css.erb file to have another syntax highlighting (CSS!).
To fix this, you simply have to do the following:
- In the TextMate menu select Bundles -> Bundle Editor -> Edit Languages
- Expand the "Ruby On Rails" item
- Select "HTML (Rails)"
- Replace "fileTypes = ( 'rhtml' );" with "fileTypes = ( 'rhtml', 'html.erb' );"
- Redo this for every language you use (i.e. CSS -> css.erb, XML -> xml.erb...) in its corresponding menu
- Now you can select a separate highlighting for every .erb extension
(via Google Groups)
Comments (5)
Daniel,
Thanks for the helpful post. Still having some problems, though. I've grabbed the latest rails bundle from the TextMate svn respository and followed your directions, but in spite of having deleted the plain '.erb' from HTML (Rails), TextMate still seems to be reading css.erb files with HTML highlighting. I've reloaded the bundles and restarted the program a number of times. Any ideas?
For CSS:
{ scopeName = 'source.css'; comment = ''; fileTypes = ( 'css', 'css.erb' ); etc.
for HTML (Rails): { scopeName = 'text.html.ruby'; fileTypes = ( 'rhtml', 'html.erb' ); foldingStartMarker = '(?x) etc.
Thanks, D
Posted by David Flaherty | 11.03.08 22:16
Posted on 11.03.08 22:16
Hi David,
so far everything looks alright with your settings. They are exactly the same as mine; and in my case this works fine.
If you didn't already do this:
Maybe you have to explicitly apply the correct syntax highlighting (CSS) for css.erb files once.
You can do this in the status bar at the bottom. Right next to "column" and "line" display, there's the drop-down menu for syntax highlighting. Open a css.erb file and then choose "CSS" in that menu.
TextMate should then remember the settings for these files.
I hope this will work out for you.
Posted by Daniel | 12.03.08 10:12
Posted on 12.03.08 10:12
Daniel,
Well, I thought that I had done that before to no avail, but it seems to have fixed the problem. Thank you so very, very much! Ahhh, TextMate, how I hate you & how I love you!
Posted by David Flaherty | 13.03.08 18:47
Posted on 13.03.08 18:47
I suppose there is no way yet to get ruby syntax in the css.erb file as we do in html.erb?
I checked the bundle editor and without knowing much about it can and it looks like it requires a specific language file set up for this.
Has anyone tackled this yet? I don't think I could fake my way through it. I thought maybe there is a way to apply "both" language types to one format.
Posted by Vern | 14.03.08 06:13
Posted on 14.03.08 06:13
Maybe one could combine code fragments of the CSS language and the HTML (Rails) language.
But I'm really not sure if this would work...
And as I don't have that many css.erb files, I haven't tried this myself.
Posted by Daniel | 14.03.08 21:15
Posted on 14.03.08 21:15