Sha256: f375108ef73dbc7f17e4d5e2249eaf1cc1b71155ff2c972f96c0c2944782d464

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

require "sass"

module Capcode
  module Helpers
    @@__SASS_PATH__ = "."
    def self.sass_path=( p )
      @@__SASS_PATH__ = p
    end
    
    def render_sass( f, _ ) #:nodoc:
      f = f.to_s
      if f.include? '..'
        return [403, {}, '403 - Invalid path']
      end
      
      if /Windows/.match( ENV['OS'] )
        unless( /.:\\/.match( @@__SASS_PATH__[0] ) )
          @@__SASS_PATH__ = File.expand_path( File.join(".", @@__SASS_PATH__) )
        end
      else
        unless( @@__SASS_PATH__[0].chr == "/" )
          @@__SASS_PATH__ = File.expand_path( File.join(".", @@__SASS_PATH__) )
        end
      end
       
      f = f + ".sass" if File.extname( f ) != ".sass"
      file = File.join( @@__SASS_PATH__, f )

      Sass::Engine.new( open( file ).read ).to_css
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
Capcode-0.8.0 lib/capcode/render/sass.rb
Capcode-0.8.1 lib/capcode/render/sass.rb