Skip to content

Instantly share code, notes, and snippets.

@mislav
Created February 26, 2009 15:06
Show Gist options
  • Save mislav/70895 to your computer and use it in GitHub Desktop.
Save mislav/70895 to your computer and use it in GitHub Desktop.
Haml monkeypatch to strip newline characters between HTML tags
require 'haml/engine'
module Haml::Precompiler
alias original_flush_merged_text flush_merged_text
def flush_merged_text
@to_merge.each_with_index do |item, i|
next_item = @to_merge[i + 1]
item[1].chomp!("\n") if item[1][0, 1] == '<' and (!next_item or next_item[1][0, 1] == '<')
end
original_flush_merged_text
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment