summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-01-17 22:55:52 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2012-01-17 22:55:52 +0100
commit8c1749d35061ee6a4954580697b523c7354de16c (patch)
tree1323948f8a2f14940e17041ddd6b2b426265a1d5
parentd0a23c4920794c9f8dd4189d7432a6b49da898d8 (diff)
downloadzorglub-8c1749d35061ee6a4954580697b523c7354de16c.zip
zorglub-8c1749d35061ee6a4954580697b523c7354de16c.tar.gz
add Sass engine
-rw-r--r--lib/zorglub/app.rb7
-rw-r--r--lib/zorglub/engines/sass.rb23
2 files changed, 29 insertions, 1 deletions
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