Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 25 lines (21 sloc) 0.863 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
# encoding: utf-8

require "rango/gv"
require "rango/mini"
require "rango/mixins/render"

module Rango
  module GV
    def self.static(template, scope = Object.new, context = Hash.new, &hook)
      Rango::Mini.app do |request, response|
        path = template || request.env["rango.router.params"][:template]
        path = hook.call(path) unless hook.nil?
        path = "#{path}.html" unless path.match(/\./)
        Rango.logger.debug("Rendering '#{path}'")
        # Rango::RenderMixin.scope
        context = context.call(request) if context.respond_to?(:call) # lambda { |request| {msg: request.message} }
        Rango::RenderMixin.render path, scope, context
      end
    end

    # you would usually define module Static with instance method static for
    # including into controllers, but since controllers have render, it would be useless
  end
end
Something went wrong with that request. Please try again.