Sha256: 6f02db40bc9f7391061933175e9d0b3f35e054a3a83fe049d12b92a22d31e61d

Contents?: true

Size: 937 Bytes

Versions: 3

Compression:

Stored size: 937 Bytes

Contents

require 'hypertemplate' unless defined? ::Hypertemplate
require "hypertemplate/hook/tilt"

module Rack
  class Hypertemplate
    
    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
    
    def call(env)
      env["hypertemplate"] = @registry
      @app.call(env)
    end
    
  end
end

module Hypertemplate
  module Hook
    module Sinatra

      module ::Sinatra::Templates

        def tokamak(template, options={}, locals={})
          hyler(template, options, locals)
        end
        
        def hyper(template, options={}, locals={})
          options.merge! :layout => false, :media_type => response["Content-Type"]
          render :hyper, template, options, locals
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hypertemplate-1.2.2 lib/hypertemplate/hook/sinatra.rb
hypertemplate-1.2.1 lib/hypertemplate/hook/sinatra.rb
hypertemplate-1.2.0 lib/hypertemplate/hook/sinatra.rb