41

If I have a method

  def some_method p = {}
    string = <<-MY_TERMINATOR
      Example text blah blah
      lorem ipsum something or another
    MY_TERMINATOR
  end

how can I access the variable p[:name] from within the heredoc?

ben
  • 29,229
  • 42
  • 124
  • 179

1 Answers1

57

You can interpolate just like in normal strings

<<-TERMINATOR
  Example #{p[:name]} blah blah blah
TERMINATOR
Chubas
  • 17,823
  • 4
  • 48
  • 48