diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2024-08-12 13:39:18 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2024-08-12 13:39:18 +0200 |
commit | c9cceed1b488a2519a827d406d0408dbbdebbc82 (patch) | |
tree | 80d42cea53c0fbccf71f8b48ad3295aac4d132fe /lib | |
parent | bc1d6ba68b2ef61ff24b48a27cd0ce412d363d49 (diff) | |
download | zorglub-c9cceed1b488a2519a827d406d0408dbbdebbc82.zip zorglub-c9cceed1b488a2519a827d406d0408dbbdebbc82.tar.gz |
fix haml engine caching and escaping
Diffstat (limited to 'lib')
-rw-r--r-- | lib/zorglub/app.rb | 3 | ||||
-rw-r--r-- | lib/zorglub/engines/haml.rb | 7 |
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 |