Sha256: 8badf801c54a7665142963dfbaf258d7ef17a47dffdb8ce83adbb2457127eb2c
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
require 'spire/http' require 'spire/resource/buffer' module Spire class MainController attr_accessor :buffer def initialize @buffer = Buffer.new end def get_buffer @buffer.data end def render(opts={}) instance_vars = {} instance_variables.each do |var| instance_vars[var] = instance_variable_get(var) end if opts[:text] @buffer.append(opts[:text]) end if opts[:view] file_path = File.join($base_path, 'views', opts[:view]) return 404 unless File.exists?(file_path) contents = IO.read(file_path) extension = File.extname(file_path) case extension when '.haml' require 'haml' insert = Haml::Engine.new(contents).render(Object.new, instance_vars) when '.rhtml' require 'erubis' eruby = Erubis::Eruby.new(contents) insert = eruby.result(instance_vars) else return false end @buffer.append(insert) end return nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spire-0.4.9 | lib/spire/class/MainController.rb |
spire-0.4.8 | lib/spire/class/MainController.rb |
spire-0.4.7 | lib/spire/class/MainController.rb |