summaryrefslogtreecommitdiffstats
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
parent6a97de5979e1f3455372d7571b8395141dcfa556 (diff)
downloadzorglub-30728f1b8b3ea3f48b3ca50def72670af8fdf570.zip
zorglub-30728f1b8b3ea3f48b3ca50def72670af8fdf570.tar.gz
add Haml engine
-rw-r--r--TODO2
-rw-r--r--lib/zorglub/config.rb7
-rw-r--r--lib/zorglub/engines/haml.rb20
3 files changed, 27 insertions, 2 deletions
diff --git a/TODO b/TODO
index f1e9eb0..6604f42 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,5 @@
-- engines
- compiled templates cache
- static pages
- development and production modes
- minimized html/js/css
+- encoding mime-type
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