diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2011-06-16 17:33:41 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2011-06-16 17:33:41 +0200 |
commit | ae5cd024e07960002f4f9bbae23b6ccb3b73b3eb (patch) | |
tree | 8281cd099d7d95ae35fd51cbfc8375834525b514 /lib | |
parent | 9afeb6e5a87e50eef1c87844e1c2923cc2680f73 (diff) | |
download | zorglub-ae5cd024e07960002f4f9bbae23b6ccb3b73b3eb.zip zorglub-ae5cd024e07960002f4f9bbae23b6ccb3b73b3eb.tar.gz |
enable view and layout usage
Diffstat (limited to 'lib')
-rw-r--r-- | lib/zorglub/config.rb | 19 | ||||
-rw-r--r-- | lib/zorglub/node.rb | 12 |
2 files changed, 19 insertions, 12 deletions
diff --git a/lib/zorglub/config.rb b/lib/zorglub/config.rb index 8b5ae37..5c43a1b 100644 --- a/lib/zorglub/config.rb +++ b/lib/zorglub/config.rb @@ -5,14 +5,12 @@ module Zorglub class Config @options = { :root => '.', - :engine => 'haml', + :engine => nil, :view_dir => 'view', :layout_dir => 'layout', :default_layout => 'default' } - @engines = { - 'haml' => 'haml' - } + @engines = { } class << self # def [] k @@ -39,14 +37,21 @@ module Zorglub end end # - def register_engine name, ext + def register_engine name, ext, proc return unless name and ext - @engines[name]=ext + @engines[name]=[ ext, proc ] end # def engine_ext engine - @engines[engine] + e = @engines[engine] + ( e.nil? ? '' : e[0] ) + end + # + def engine_proc engine + e = @engines[engine] + ( e.nil? ? nil : e[1] ) end + # end # def self.method_missing m, *args, &block diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb index 99d6c5d..08214a3 100644 --- a/lib/zorglub/node.rb +++ b/lib/zorglub/node.rb @@ -55,11 +55,13 @@ module Zorglub end # def realize - # TODO - # - use view - # - use layout - r = self.send @action[:method], *@action[:args] - response.write r + @content = self.send @action[:method], *@action[:args] + e = Config.engine_proc @action[:engine] + v = view + l = layout + @content = e.call v, self if e and File.exists? v + @content = e.call l, self if e and File.exists? l + response.write @content response.finish end # |