A Rails layout
<%= image_tag("logo.png", :alt => "Sample App", :class => "round") %>
will render as the HTML
<img alt="Sample App" class="round" src="/images/logo.png" />
Will web pages load noticeably slower if they have to render a page versus getting the HTML directly? I’m trying to figure out the advantage of writing HTML in Ruby, except perhaps for convenience?
Advantage of dynamically generated HTML
In your simple example, it’s actually not important which one of your two options you use. Having a templating system like ERB is however necessary if as you want to create dynamic content, like in this example:
You cannot do this with static HTML.
Performance
Dynamically generating the HTML like this before serving it will obviously take a bit longer than serving static HTML. Rails has caching built in, however, so you can easily control the impact of this.