diff options
-rw-r--r-- | lib/zorglub/app.rb | 3 | ||||
-rw-r--r-- | lib/zorglub/engines/haml.rb | 7 | ||||
-rw-r--r-- | spec/data/view/node0/engines.haml | 2 | ||||
-rw-r--r-- | spec/node_spec.rb | 4 | ||||
-rw-r--r-- | spec/spec_helper.rb | 1 |
5 files changed, 10 insertions, 7 deletions
diff --git a/lib/zorglub/app.rb b/lib/zorglub/app.rb index 86adf1e..91635ab 100644 --- a/lib/zorglub/app.rb +++ b/lib/zorglub/app.rb @@ -18,7 +18,8 @@ module Zorglub engines: {}, haml_options: { format: :html5, - encoding: 'utf-8' + encoding: 'utf-8', + escape_html: false }, sass_options: { syntax: :scss, diff --git a/lib/zorglub/engines/haml.rb b/lib/zorglub/engines/haml.rb index b602773..0031eec 100644 --- a/lib/zorglub/engines/haml.rb +++ b/lib/zorglub/engines/haml.rb @@ -5,12 +5,13 @@ module Zorglub module Engines module Haml def self.proc(path, obj) - haml = ::Haml::Template.new(path) if obj.app.opt(:engines_cache_enabled) key = path.sub obj.app.opt(:root), '' - obj.app.engines_cache[key] ||= haml + haml = obj.app.engines_cache[key] || ::Haml::Template.new(obj.app.opt(:haml_options)) { ::File.read(path) } + else + haml = ::Haml::Template.new(obj.app.opt(:haml_options)) { ::File.read(path) } end - html = haml.render(obj, obj.app.opt(:haml_options)) + html = haml.render(obj) [html, 'text/html'] end end diff --git a/spec/data/view/node0/engines.haml b/spec/data/view/node0/engines.haml index b9ea984..d35145e 100644 --- a/spec/data/view/node0/engines.haml +++ b/spec/data/view/node0/engines.haml @@ -1 +1 @@ -%h1="Hello world" +%h1="Hello #{@name}" diff --git a/spec/node_spec.rb b/spec/node_spec.rb index fe1edfb..785da42 100644 --- a/spec/node_spec.rb +++ b/spec/node_spec.rb @@ -266,10 +266,10 @@ describe Zorglub do it 'haml engine should work' do Node0.app.opt! :engines_cache_enabled, false r = Node0.my_call '/engines/haml' - expect(r.body[0]).to eq "<h1>Hello world</h1>\n" + expect(r.body[0]).to eq "<h1>Hello <i>world</i></h1>\n" Node0.app.opt! :engines_cache_enabled, true r = Node0.my_call '/engines/haml' - expect(r.body[0]).to eq "<h1>Hello world</h1>\n" + expect(r.body[0]).to eq "<h1>Hello <i>world</i></h1>\n" end it 'sass engine should work' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 257327e..079607b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -112,6 +112,7 @@ class Node0 < Zorglub::Node no_layout! case name when 'haml' + @name = '<i>world</i>' engine! :haml when 'sass' engine! :sass |