Module: Capcode::Helpers
- Defined in:
- lib/capcode/render/less.rb
Instance Method Summary collapse
-
#render_less(f, opts) ⇒ Object
:nodoc:.
Instance Method Details
#render_less(f, opts) ⇒ Object
:nodoc:
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/capcode/render/less.rb', line 9 def render_less( f, opts ) #:nodoc: if @less_path.nil? @less_path = Capcode::Configuration.get( :less ) || Capcode.static() end f = f.to_s if f.include? '..' return [403, {}, '403 - Invalid path'] end if /Windows/.match( ENV['OS'] ) unless( /.:\\/.match( @less_path[0] ) ) @less_path = File.( File.join(".", @less_path) ) end else unless( @less_path[0].chr == "/" ) @less_path = File.( File.join(".", @less_path) ) end end # Get less File f = f + ".less" if File.extname( f ) != ".less" file = File.join( @less_path, f ) # Set content-type @response['Content-Type'] = "text/css" # Render if( File.exist?( file ) ) Less::Engine.new(open(file)).to_css else raise Capcode::RenderError, "Error rendering `less', #{file} does not exist !" end end |