From 30728f1b8b3ea3f48b3ca50def72670af8fdf570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 5 Jan 2012 09:55:21 +0100 Subject: add Haml engine --- TODO | 2 +- lib/zorglub/config.rb | 7 ++++++- lib/zorglub/engines/haml.rb | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 lib/zorglub/engines/haml.rb 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 -- cgit v1.1-2-g2b99