title: Sinatra - render "erb" within Module
body: <p>How can I use <code>erb</code> within a Module in Sinatra? Here is an example of a complete app, where <code>erb</code> fails within a Module.</p>
  
  <pre><code>require 'sinatra'
  
  get '/yes' do
    erb "&lt;%= Time.now %&gt;" #works
  end
  
  get '/no' do 
    MyMod.foo #fails
  end
  
  module MyMod
    extend self
  
    def foo
      erb "&lt;%= Time.now %&gt;" #fails: undefined method `erb' for MyMod:Module
    end
  end
  </code></pre>