lib/capcode/render/haml.rb in Capcode-0.5.0 vs lib/capcode/render/haml.rb in Capcode-0.6.0

- old
+ new

@@ -1,19 +1,23 @@ require "haml" module Capcode module Helpers - @@__HAML_PATH__ = File.expand_path( "." ) + @@__HAML_PATH__ = "." def self.haml_path=( p ) - @@__HAML_PATH__ = File.expand_path( p ) + @@__HAML_PATH__ = p end def render_haml( f ) #:nodoc: f = f.to_s if f.include? '..' return [403, {}, '403 - Invalid path'] end - + + unless( @@__HAML_PATH__[0].chr == "/" ) + @@__HAML_PATH__ = File.expand_path( File.join(@@__ROOT_DIRECTORY, @@__HAML_PATH__) ) + end + f = f + ".haml" if File.extname( f ) != ".haml" file = File.join( @@__HAML_PATH__, f ) Haml::Engine.new( open( file ).read ).to_html( self ) end end \ No newline at end of file