Sha256: 588cc63ba0fc95b0ef8405e75b15aa9a70c3e3efbcfce12c94213c6e1bcf4ab8
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
require 'erb' module Capcode module Helpers @@__ERB_PATH__ = "." def self.erb_path=( p ) @@__ERB_PATH__ = p end def get_binding binding end def render_erb( f, opts ) #:nodoc: f = f.to_s if f.include? '..' return [403, {}, '403 - Invalid path'] end if /Windows/.match( ENV['OS'] ) unless( /.:\\/.match( @@__ERB_PATH__[0] ) ) @@__ERB_PATH__ = File.expand_path( File.join(".", @@__ERB_PATH__) ) end else unless( @@__ERB_PATH__[0].chr == "/" ) @@__ERB_PATH__ = File.expand_path( File.join(".", @@__ERB_PATH__) ) end end layout = opts.delete(:layout)||:layout layout_file = File.join( @@__ERB_PATH__, layout.to_s+".rhtml" ) f = f + ".rhtml" if File.extname( f ) != ".rhtml" file = File.join( @@__ERB_PATH__, f ) if( File.exist?( layout_file ) ) ERB.new(open(layout_file).read).result( get_binding { |*args| @@__ARGS__ = args ERB.new(open(file).read).result(binding) } ) else ERB.new(open(file).read).result(binding) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
Capcode-0.8.0 | lib/capcode/render/erb.rb |
Capcode-0.8.1 | lib/capcode/render/erb.rb |