Technical.Web

Technical.Projects

Jeweler is the GitHub recommended way to generating and maintaining RubyGem projects.

Daywalker is a Ruby library for accessing data about congressional districts and legislators using the Sunlight API.

Technical.Stats

Follow up: Haml no longer be blowing my spot

I just barely posted about Haml blowin my spot. Thanks to the kindness of a reader, Haml is no longer blowin my spot.

The problem

Imagine we have the following snippet:

%div{ :id => "post_#{ post.id }" }
  %h2{:class => 'post_title'}= post.title
  .post_content= post.cached_content

This post.cached_content contains some <pre> tags. As a result, the contents get kind of skewed.

The fix

So, it seems you can do something like:

%div{ :id => "post_#{ post.id }" }
  %h2{:class => 'post_title'}= post.title
  .post_content~ post.cached_content

The key here is that we use ~ instead of = to output stuff. Apparently this is an alias for Haml::Helpers.find_and_preserve. I actually didn’t see any documentation about this alias though.

Looking to the future

Nathan Weizenbaum also pointed out that “Incidentally, as of Haml 1.9 pre and textarea will automatically eschew indentation-management.” Sick!

blog comments powered byDisqus