lib/hamlit/compilers/text.rb in hamlit-1.4.1 vs lib/hamlit/compilers/text.rb in hamlit-1.4.2
- old
+ new
@@ -17,11 +17,11 @@
# This constant is the candidates for the literal surrounder.
STRING_MARKERS = %w[' " ! @ $ % ^ & * | =].freeze
# Return static and dynamic temple ast.
# It splits expression to optimize because string interpolation is slow.
- def on_haml_text(exp)
+ def on_haml_text(exp, escape_html = true)
return static_text(exp) unless contains_interpolation?(exp)
marker = find_string_marker(exp)
return [:dynamic, string_literal(exp)] unless marker
@@ -29,10 +29,12 @@
return static_text(exp) unless open_pos && close_pos
pre = exp.byteslice(0...open_pos)
body = exp.byteslice((open_pos + 2)...close_pos)
post = exp.byteslice((close_pos + 1)...exp.bytesize)
- [:multi, [:static, pre], escape_html([:dynamic, body]), on_haml_text(post)]
+
+ body_ast = escape_html ? escape_html([:dynamic, body]) : [:dynamic, body]
+ [:multi, [:static, pre], body_ast, on_haml_text(post)]
end
def find_interpolation(exp, marker)
return unless contains_interpolation?(exp)