Class: Hexp::Unparser
- Inherits:
-
Object
- Object
- Hexp::Unparser
- Includes:
- Adamantium
- Defined in:
- lib/hexp-rails.rb,
lib/hexp/unparser.rb
Overview
Honor ActiveSupport::SafeBuffer’s “html_safe” flag
Constant Summary collapse
- APOS =
?'.freeze
- QUOT =
?".freeze
- LT =
'<'.freeze
- GT =
'>'.freeze
- SPACE =
' '.freeze
- EQ =
'='.freeze
- AMP =
'&'.freeze
- FSLASH =
'/'.freeze
- E_AMP =
'&'.freeze
- E_APOS =
'''.freeze
- E_QUOT =
'"'.freeze
- E_LT =
'<'.freeze
- E_GT =
'>'.freeze
- ESCAPE_ATTR_APOS =
{AMP => E_AMP, APOS => E_APOS}
- ESCAPE_ATTR_QUOT =
{AMP => E_AMP, QUOT => E_QUOT}
- ESCAPE_TEXT =
{AMP => E_AMP, APOS => E_APOS, QUOT => E_QUOT, LT => E_LT, GT => E_GT}
- ESCAPE_ATTR_APOS_REGEX =
Regexp.new("[#{ESCAPE_ATTR_APOS.keys.join}]")
- ESCAPE_ATTR_QUOT_REGEX =
Regexp.new("[#{ESCAPE_ATTR_QUOT.keys.join}]")
- ESCAPE_TEXT_REGEX =
Regexp.new("[#{ESCAPE_TEXT.keys.join}]")
- DEFAULT_OPTIONS =
{ encoding: Encoding.default_external, no_escape: [:script], void: [ :area, :base, :br, :col, :command, :embed, :hr, :img, :input, :keygen, :link, :meta, :param, :source, :track, :wbr ] }
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #call(node) ⇒ Object
-
#initialize(options) ⇒ Unparser
constructor
A new instance of Unparser.
- #orig_escape_text ⇒ Object
Constructor Details
#initialize(options) ⇒ Unparser
Returns a new instance of Unparser.
37 38 39 |
# File 'lib/hexp/unparser.rb', line 37 def initialize() @options = DEFAULT_OPTIONS.merge() end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
35 36 37 |
# File 'lib/hexp/unparser.rb', line 35 def @options end |
Instance Method Details
#call(node) ⇒ Object
41 42 43 44 45 |
# File 'lib/hexp/unparser.rb', line 41 def call(node) buffer = String.new.force_encoding([:encoding]) add_node(buffer, node) buffer.freeze end |
#orig_escape_text ⇒ Object
26 |
# File 'lib/hexp-rails.rb', line 26 alias orig_escape_text escape_text |