> > In real applications (such as CGI), I always write the method which
> > build sub part in Ruby script.
> 
> Can one pass variables to imported files this way?

How about using instance variablies? 

--- nav.erb
<%= @a ||= 10 %>

--- test.rb
require 'erb/erbl'

class PageWriter
  def initialize(template)
    @erb = ERbLight.new(template)
  end
	
  def import(path)
    File.open(path) do |f|
      ERbLight.new(f.read)
    end.result(binding)
  end

  def navi
    import('nav.erb')
  end

  def to_html 
    @erb.result(binding)
  end
end


template = '<html>
<%= @a=4; navi %>
</html>'

print PageWriter.new(template).to_html