summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2024-08-12 13:39:18 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2024-08-12 13:39:18 +0200
commitc9cceed1b488a2519a827d406d0408dbbdebbc82 (patch)
tree80d42cea53c0fbccf71f8b48ad3295aac4d132fe /lib
parentbc1d6ba68b2ef61ff24b48a27cd0ce412d363d49 (diff)
downloadzorglub-c9cceed1b488a2519a827d406d0408dbbdebbc82.zip
zorglub-c9cceed1b488a2519a827d406d0408dbbdebbc82.tar.gz
fix haml engine caching and escaping
Diffstat (limited to 'lib')
-rw-r--r--lib/zorglub/app.rb3
-rw-r--r--lib/zorglub/engines/haml.rb7
2 files changed, 6 insertions, 4 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