From 8c1749d35061ee6a4954580697b523c7354de16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 17 Jan 2012 22:55:52 +0100 Subject: add Sass engine --- lib/zorglub/app.rb | 7 ++++++- lib/zorglub/engines/sass.rb | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 lib/zorglub/engines/sass.rb diff --git a/lib/zorglub/app.rb b/lib/zorglub/app.rb index 553dd3f..3d2819b 100644 --- a/lib/zorglub/app.rb +++ b/lib/zorglub/app.rb @@ -25,11 +25,16 @@ module Zorglub :ugly => false, :encoding => 'utf-8' }, + :sass_options => { + :syntax => :scss, + :cache => :false, + :style => :compressed + }, :session_options => { :enabled => false, :key => 'zorglub.sid', :secret => 'session-secret-secret', - :sid_len => 64, + :sid_len => 64 } } instance_eval &block if block_given? diff --git a/lib/zorglub/engines/sass.rb b/lib/zorglub/engines/sass.rb new file mode 100644 index 0000000..dd0eadb --- /dev/null +++ b/lib/zorglub/engines/sass.rb @@ -0,0 +1,23 @@ +# -*- coding: UTF-8 -*- +# +require 'sass/util' +require 'sass/engine' +# +module Zorglub + module Engines + module Sass + def self.proc path,obj + if obj.app.opt(:engines_cache_enabled) + key = path.sub obj.app.opt(:root),'' + sass = obj.app.engines_cache[key] ||= ::Sass::Engine.new( ::File.open(path,'r'){|f| f.read }, obj.app.opt(:sass_options) ) + else + sass = ::Sass::Engine.new( ::File.open(path,'r'){|f| f.read }, obj.app.opt(:sass_options) ) + end + css = sass.render + return css, 'text/css' + end + end + end +end +# +# EOF -- cgit v1.1-2-g2b99