Sha256: 623756a8e8e3a42867adfb677f14d3ab208f88417b989942d9a35dd49da8044b
Contents?: true
Size: 997 Bytes
Versions: 1
Compression:
Stored size: 997 Bytes
Contents
module Slim module Smart # Perform smart entity escaping in the # expressions `[:slim, :text, type, Expression]`. # # @api private class Escaper < ::Slim::Filter define_options :smart_text_escaping => true def call(exp) if options[:smart_text_escaping] super else exp end end def on_slim_text(type, content) [:escape, type != :verbatim, [:slim, :text, type, compile(content)]] end def on_static(string) # Prevent obvious &foo; and Ӓ and ÿ entities from escaping. block = [:multi] until string.empty? case string when /\A&(\w+|#x[0-9a-f]+|#\d+);/i # Entity. block << [:escape, false, [:static, $&]] string = $' when /\A&?[^&]*/ # Other text. block << [:static, $&] string = $' end end block end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slim-2.1.0 | lib/slim/smart/escaper.rb |