summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-01-05 09:55:21 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2012-01-05 09:55:21 +0100
commit30728f1b8b3ea3f48b3ca50def72670af8fdf570 (patch)
treeeddbd503b13f41f849043d5f9b0f7aa2db0bbafe /lib
parent6a97de5979e1f3455372d7571b8395141dcfa556 (diff)
downloadzorglub-30728f1b8b3ea3f48b3ca50def72670af8fdf570.zip
zorglub-30728f1b8b3ea3f48b3ca50def72670af8fdf570.tar.gz
add Haml engine
Diffstat (limited to 'lib')
-rw-r--r--lib/zorglub/config.rb7
-rw-r--r--lib/zorglub/engines/haml.rb20
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/zorglub/config.rb b/lib/zorglub/config.rb
index d38e7fc..d648958 100644
--- a/lib/zorglub/config.rb
+++ b/lib/zorglub/config.rb
@@ -12,7 +12,12 @@ module Zorglub
:session_on => false,
:session_key => 'zorglub.sid',
:session_secret => 'session-secret-secret',
- :session_sid_len => 64
+ :session_sid_len => 64,
+ :haml_options => {
+ :format => :html5,
+ :ugly => false,
+ :encoding => 'utf-8'
+ }
#
}
@engines = { }
diff --git a/lib/zorglub/engines/haml.rb b/lib/zorglub/engines/haml.rb
new file mode 100644
index 0000000..8c7bce0
--- /dev/null
+++ b/lib/zorglub/engines/haml.rb
@@ -0,0 +1,20 @@
+# -*- coding: UTF-8 -*-
+#
+require 'haml/util'
+require 'haml/engine'
+#
+module Zorglub
+ module Engines
+ module Haml
+ def self.proc path,obj
+ haml = ::Haml::Engine.new( File.open(path,'r').read, Zorglub::Config.haml_options )
+ html = haml.render(obj)
+ return html, 'text/html'
+ end
+ end
+ end
+end
+#
+Zorglub::Config.register_engine :haml, 'haml', Zorglub::Engines::Haml.method(:proc)
+#
+# EOF