Hello.

> But where is ERuby::Compiler defined?  I see the Debian package only
> installed /usr/bin/eruby and no lib file at all.  Is it a 1.7 thing?
> 
> > If you do this within a page object:
> > 
> > class Page
> >   @template = "path/to/template"
> >   def to_html
> >     eval( compile_eruby(@template) )
> >   end
> > end
> > 
> > Then the code in the template gets eval'd in the scope of the page,
> 
> Do you mean that if the Page class has a ``foo'' attribute, <% =foo %>
> will be translated into that?

Do you know erb? 
You can change an eRuby script into a method by erb. 

I'm writing erb tutorial (in Japanese). # It'l be translated in 
the near future. The following samples are in the tutorial.
 -> http://www.jin.gr.jp/~nahi/RWiki/index.cgi?cmd=view;name=ERbMemo

FYI: There is web application called Div using this. (machine translated)
 -> http://www.jin.gr.jp/~nahi/RWiki/index.cgi?cmd=view;name=Div
 -> http://www.jin.gr.jp/~nahi/RWiki/index.cgi?cmd=view;name=YourFirstDiv



--batch.rb--
require 'erb/erbl'
require 'erb/erbu'
require 'forwardable'

class Writer
  extend Forwardable
  extend ERbMethod
  include ERbUtil

  def initialize(page)
    @page = page
  end
  
  def_delegators(:@page, :title, :abstract, :content, :modified)
  def_delegators(:@page, :hier)

  def_erb_method('body', 'body.erb')
  def_erb_method('footer', 'footer.erb')
  def_erb_method('navi', 'navi.erb')

  def write_to_file
    fname = File.basename(@page.url)
    File.open(fname, 'w') do |fp|
      fp.puts(body)
    end
  end
end

Article = Struct.new(:url, :title, 
		     :abstract, :content, 
		     :modified, :hier)

class Book
  extend ERbMethod
  include ERbUtil

  def initialize
    @url = 'index.html'
    @title = 'index'
    @index = []
  end
  attr_accessor :url, :title
  attr_reader :index
  
  def add(article)
    @index.push(article)
    article.hier = [self]
  end

  def abstract; nil; end
  def_erb_method('content', 'index.erb')
  def modified; nil end
  def hier; nil; end
end

def main
  book = Book.new

  it = Article.new('hello.html', 'Hello', 
		   '<p>Hello, World.</p>',
		   '<h2>Hello</h2><p>Test Artcile 1.</p>',
		   Time.now-24*60*60, nil)

  book.add(it)

  it = Article.new('hello2.html', 'Hello2', 
		   '<p>Hello, World, too.</p>',
		   '<h2>Hello2</h2><p>Test Artcile 2.</p>',
		   Time.now, nil)
		 
  book.add(it)
  
  Writer.new(book).write_to_file
  
  book.index.each do |pg|
    Writer.new(pg).write_to_file
  end
end

main

-- body.erb --
<html>
<head>
<title><%=h title %></title>
</head>
<body>
<%= navi %>

<div class="abstract">
<h1><%=h title %></h1>
<%= abstract %>
</div>

<%= content %>
<%= footer %>
</body>
</html>

-- footer.erb --
<div class="footer">
<p>
<% if modified %>Modified: <%=h modified.strftime("%Y-%m-%d") %><% end %>
</p>
</div>

-- navi.erb --
<% if hier %>
<div class="navi">
<% hier.each do |n| %>
[<a href="<%=n.url%>"><%=h n.title%></a>]
<% end %>
</div>
<% end %>

-- index.erb --
<ul>
<% index.each do |pg|%>
<li><a href="<%= pg.url%>"><%=h pg.title %></a></li>
<% end %>
</ul>