Sunday, February 5, 2012

Still working on taming Emacs

I find that I often get tripped up by little things when it comes to programming. For example, I was going through that haml tutorial I posted about a couple of days ago, and I wondered exactly how Rails would know to use the haml file instead of the old erb file. After all, I'd already installed the gem and listed it in the Gemfile.

It turns out I didn't have to do anything else. I could have just renamed the .erb file to use a .haml extension. Luckily this didn't take long to figure out, but I've got a history of overlooking things like this that should be fairly obvious.

haml itself is easy enough to understand. Take those dirty div tags for example!

<div class="content">AWESOME CONTENT</div>


Is magically transformed into

.content AWESOME CONTENT


EDIT: Corrected this information, thanks to Joel. In haml, a . signifies a class, whereas a # signifies an id.

There's more to haml than this, but it's an abstraction of XHTML which makes writing code easier and less tedious. I was thinking of taking the time to do a more in-depth tutorial for haml, but instead I'm going to incorporate it into this Twitter Bootstrap for Rails 3.1 tutorial series my buddy Joel sent my way.

I hope you guys like reading about Twitter Bootstrap, because that's absolutely what I'll be blogging about this week.

I've also made some progress with Emacs, and no longer feel lost when trying to do basic things like open recent files. I've definitely got some work to do before I feel really comfortable coding with Emacs, but I don't think it'll take long to get the basics down. I went through the notes I made at Fort Behavior last week and threw them into a .txt file, so I'll just have that open when using Emacs until I don't need it.

4 comments:

  1. #content AWESOME CONTENT

    dots for classes.
    octothorpe for ids.

    :)

    ReplyDelete
    Replies
    1. Awesome, thanks for the correction! I was assuming dots were just for divs in general, and didn't think about class v. id.

      Delete
  2. Good idea! I need to take some notes on using Emacs, as well. I so many different Emacs tabs open for reference, I can't find anything when I actually need it. I end up either asking in the #indyrb IRC channel, or Googling.

    Did you end up starting from scratch, or are you using the Emacs Start Kit? https://github.com/technomancy/emacs-starter-kit

    ReplyDelete
    Replies
    1. The other EB guys have been giving me a lot of help getting started, and Joel's sent me some helpful links that I've been looking through in the evenings. I'll give the starter kit a shot this evening, though!

      Delete