Showing posts with label os x leopard xcode erb ruby on rails. Show all posts
Showing posts with label os x leopard xcode erb ruby on rails. Show all posts

Sunday, March 15, 2009

XCode ERB file highlighting

Ok...  I've been trying to use XCode 3.1.2 to edit Ruby on Rails projects, and choking every time I load up an ERB file.  XCode just doesn't recognize the syntax.  I have, in numerous sessions, searched for the correct solution, and then, this morning, while thinking, I had a brainwave!  Follow this:

  • OS X 10.5/Leopard comes with Ruby on Rails 1.8.5
  • RoR 1.8.5 uses the RHTML file extension
  • I made a RHTML file, and there you go!  It works in XCode
  • I searched through the OS X libraries for the reference, and found it
Here's the answer:
  1. Open this file in a text editor:/Developer/Library/PrivateFrameworks/DevToolsCore.framework/Versions/A/Resources/Standard file types.pbfilespec
  2. Search for rhtml, and you'll find this line:  Extensions = (shtml, jsp, rhtml);
  3. Change it to this: Extensions = (shtml, jsp, rhtml, erb);
In other words, add the ERB file extension to the list of files the developer tools recognize as Embedded Ruby Code.  XCode should now highlight ERB files correctly.

Why didn't one of the Apple developers post this months ago?