This guide examines how to parse a Ruby Heredoc object and convert any lines with a hashtag to HTML H1 headings.
Parse a Ruby Heredoc and replace any lines that start with a hashtag with HTML H1 heading tags.
Given a Ruby Heredoc string, replace any lines that start with a hashtag and wrap them in HTML H1 heading tags.
content = <<-EOF # Hey there Some content # Another heading More content EOF
"<h1>Hey there</h1>\n\nSome content\n\n<h1>Another heading</h1>\n\nMore content\n"
Real World Usage
When it comes to working with Rails helper methods, it’s important to understand how to parse large strings and replace patterns with other strings.
Can be found on the solutions branch on github.