# Creating MarkDown documents in ruby

I'm trying to dynamically generate some MarkDown formatted documents, with header fields of arbitrary lengths.

I want to have a title of arbitrary length underlined like this
---------------------------------------------------------------

This should work to
-------------------


The code I came up with to do this in my ERB views.

<%= @title %>
<%= @title.length.times.map{"-"}.join %>


Is there a more efficient way to make this happen?

-

"-" * @title.length #=> "---------------"

Warning: Make sure you put the String first or else you will get a TypeError: String can't be coerced into Fixnum since that would be calling Fixnum#* instead of String#*.