diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/zorglub/app.rb | 2 | ||||
| -rw-r--r-- | lib/zorglub/config.rb | 1 | ||||
| -rw-r--r-- | lib/zorglub/engines/haml.rb | 7 | ||||
| -rw-r--r-- | lib/zorglub/node.rb | 6 | 
4 files changed, 14 insertions, 2 deletions
| diff --git a/lib/zorglub/app.rb b/lib/zorglub/app.rb index 635f511..fa4ff6b 100644 --- a/lib/zorglub/app.rb +++ b/lib/zorglub/app.rb @@ -11,7 +11,9 @@ module Zorglub              @map = map              instance_eval &block if block_given?              remap @map +            @engines_cache = { }          end +        attr_reader :engines_cache          #          def map location, object              return unless location and object diff --git a/lib/zorglub/config.rb b/lib/zorglub/config.rb index d648958..26fd449 100644 --- a/lib/zorglub/config.rb +++ b/lib/zorglub/config.rb @@ -13,6 +13,7 @@ module Zorglub              :session_key => 'zorglub.sid',              :session_secret => 'session-secret-secret',              :session_sid_len => 64, +            :engines_cache_enabled => true,              :haml_options => {                  :format => :html5,                  :ugly => false, diff --git a/lib/zorglub/engines/haml.rb b/lib/zorglub/engines/haml.rb index 8c7bce0..8cfb847 100644 --- a/lib/zorglub/engines/haml.rb +++ b/lib/zorglub/engines/haml.rb @@ -7,7 +7,12 @@ module Zorglub      module Engines          module Haml              def self.proc path,obj -                haml = ::Haml::Engine.new( File.open(path,'r').read, Zorglub::Config.haml_options ) +                if Zorglub::Config.engines_cache_enabled +                    key = path.sub Zorglub::Config.root,'' +                    haml = obj.app.engines_cache[key] ||= ::Haml::Engine.new( File.open(path,'r').read, Zorglub::Config.haml_options ) +                else +                    haml = ::Haml::Engine.new( File.open(path,'r').read, Zorglub::Config.haml_options ) +                end                  html = haml.render(obj)                  return html, 'text/html'              end diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb index 2e46bdf..68e535b 100644 --- a/lib/zorglub/node.rb +++ b/lib/zorglub/node.rb @@ -41,7 +41,7 @@ module Zorglub                  var              end              # -            attr_writer :app +            attr_accessor :app              def map app, location                  @app = app                  @app.map location, self @@ -176,6 +176,10 @@ module Zorglub              d          end          # +        def app +            self.class.app +        end +        #          def args              @options[:args]          end | 
