Class: Rack::Hypertemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/hypertemplate/hook/sinatra.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Hypertemplate

Returns a new instance of Hypertemplate.



7
8
9
10
11
12
13
14
15
16
# File 'lib/hypertemplate/hook/sinatra.rb', line 7

def initialize(app)
  @app = app
  @registry = ::Hypertemplate::Registry.new
  if block_given?
    yield @registry
  else
    @registry << ::Hypertemplate::Builder::Json
    @registry << ::Hypertemplate::Builder::Xml
  end
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
# File 'lib/hypertemplate/hook/sinatra.rb', line 18

def call(env)
  env["hypertemplate"] = @registry
  @app.call(env)
end