Skip to content

Commit 07f23be

Browse files
committed
Change HAML setup to support newer versions
1 parent 1555f27 commit 07f23be

3 files changed

Lines changed: 26 additions & 12 deletions

File tree

CHANGES.rdoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
= CHANGES
22

3+
== 0.16.1 (2025-12-12)
4+
5+
- FIX #2312 Change HAML setup to support newer versions (@crashtech)
6+
- FIX #2311 Loosen bundler version pinning (achiurizo)
7+
38
== 0.16.0 (2025-12-02)
49

510
- NEW Code modernization. Codebase is now passing Rubocop and generator's templates are using modern syntax (@crashtech)

padrino-helpers/lib/padrino/rendering.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,6 @@ def content_type_symbol(type)
405405
unless defined? Padrino::Rendering::HamlTemplate
406406
begin
407407
require 'haml'
408-
require 'haml/helpers/xss_mods'
409-
require 'haml/helpers/action_view_extensions'
410408
rescue LoadError
411409
# do nothing since haml is not available
412410
else
Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
module Haml
2-
module Helpers
3-
include XssMods
4-
include ActionViewExtensions
5-
end
1+
begin
2+
using_modern_haml = false
3+
require 'haml/helpers/xss_mods'
4+
require 'haml/helpers/action_view_extensions'
5+
6+
module Haml
7+
Helpers.include(Helpers::XssMods)
8+
Helpers.include(Helpers::ActionViewExtensions)
69

7-
module Util
8-
def self.rails_xss_safe?
10+
def Util.rails_xss_safe?
911
true
1012
end
1113
end
14+
rescue LoadError
15+
using_modern_haml = true
1216
end
1317

1418
module Padrino
@@ -21,6 +25,13 @@ class HamlTemplate < Tilt::HamlTemplate
2125

2226
Tilt.prefer(Padrino::Rendering::HamlTemplate, :haml)
2327

24-
Padrino::Rendering.engine_configurations[:haml] = {
25-
escape_html: true
26-
}
28+
Padrino::Rendering.engine_configurations[:haml] =
29+
if using_modern_haml
30+
{
31+
buffer_class: 'SafeBuffer.new',
32+
use_html_safe: true,
33+
disable_capture: true
34+
}
35+
else
36+
{ escape_html: true }
37+
end

0 commit comments

Comments
 (0)