Class: RSX::SafeString
- Inherits:
-
String
- Object
- String
- RSX::SafeString
- Defined in:
- lib/rsx/safe_string.rb
Overview
An HTML-safe string. Anything wrapped in a SafeString is emitted verbatim; everything else that flows into a template is escaped.
SafeString subclasses String so it interoperates with ActionView output buffers, ActiveSupport::SafeBuffer and plain Ruby string operations without requiring ActiveSupport to be loaded.
Instance Method Summary collapse
- #*(times) ⇒ Object
-
#+(other) ⇒ Object
Concatenation keeps the safety contract: unsafe operands are escaped.
- #<<(other) ⇒ Object (also: #concat)
- #html_safe? ⇒ Boolean
- #inspect ⇒ Object
-
#to_s ⇒ Object
Rails calls this when concatenating into an output buffer.
- #to_safe_string ⇒ Object
Instance Method Details
#*(times) ⇒ Object
34 35 36 |
# File 'lib/rsx/safe_string.rb', line 34 def *(times) SafeString.new(super) end |
#+(other) ⇒ Object
Concatenation keeps the safety contract: unsafe operands are escaped.
25 26 27 |
# File 'lib/rsx/safe_string.rb', line 25 def +(other) SafeString.new(super(RSX.child(other))) end |
#<<(other) ⇒ Object Also known as: concat
29 30 31 |
# File 'lib/rsx/safe_string.rb', line 29 def <<(other) super(RSX.child(other)) end |
#html_safe? ⇒ Boolean
11 12 13 |
# File 'lib/rsx/safe_string.rb', line 11 def html_safe? true end |
#inspect ⇒ Object
38 39 40 |
# File 'lib/rsx/safe_string.rb', line 38 def inspect "#<RSX::SafeString #{super}>" end |
#to_s ⇒ Object
Rails calls this when concatenating into an output buffer.
16 17 18 |
# File 'lib/rsx/safe_string.rb', line 16 def to_s self end |
#to_safe_string ⇒ Object
20 21 22 |
# File 'lib/rsx/safe_string.rb', line 20 def to_safe_string self end |