This is actually somewhat tricky. Rails does a lot for you in this area.
Here's something to get you started:
<%= ERB.new(IO.read('subtemplate.rhtml'), nil, nil, '_erbout2').result %>
What ERB does is to take your template and turn it into pure Ruby code
that builds up a string using a variable name called (by default)
'_erbout'. When you call result(), the ruby code is eval'd in the
context of the binding passed (or TOPLEVEL_BINDING if no binding is
To do a sub-template, you need to eval the sub-template and insert
it's results mid-stream. But all the eval-ing happens at once (when
you do the outermost template), so you need to use a different output
variable name in your subtemplate, or your subtemplate will stomp on
the output of your outer template. Hence the '_erbout2' parameter to
new(). If the subtemplate called yet another subtemplate, you would
need another variable name, and so forth, for each level of nesting.