dznqbit

Stupid Ruby Tricks: pre Tags Inside Haml Without Going Insane

Stuffing some genius code inside <pre> tags?

Use a squiggly HEREDOC .

%h1 It's Ruby!

:ruby
  my_ruby_code = <<~'EOS'
    next_level = [1, 2, 3].map do |i|
      i + 1
    end

    puts next_level.join(" ")
  EOS

%pre= my_ruby_code