Class: Bridgetown::OutputBuffer
- Inherits:
-
Object
- Object
- Bridgetown::OutputBuffer
- Extended by:
- Forwardable
- Defined in:
- bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb
Instance Method Summary collapse
-
#<<(value) ⇒ Object
(also: #append=)
Concatenation for <%= %> expressions, whose output is escaped.
-
#==(other) ⇒ Object
rubocop:enable Naming/BinaryOperatorParameterName.
-
#html_safe ⇒ Object
-
#html_safe? ⇒ Boolean
-
#initialize(buffer = "") ⇒ OutputBuffer
constructor
A new instance of OutputBuffer.
-
#initialize_copy(other) ⇒ Object
-
#safe_concat(value) ⇒ Object
(also: #safe_append=)
-
#safe_expr_append=(val) ⇒ Object
-
#to_s ⇒ Object
-
#to_str ⇒ Object
-
#|(value) ⇒ Object
Concatenation for <%== %> expressions, whose output is not escaped.
Constructor Details
#initialize(buffer = "") ⇒ OutputBuffer
Returns a new instance of OutputBuffer.
22 23 24 25 |
# File 'bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb', line 22 def initialize(buffer = "") @buffer = String.new(buffer) @buffer.encode! end |
Instance Method Details
#<<(value) ⇒ Object Also known as: append=
Concatenation for <%= %> expressions, whose output is escaped.
32 33 34 35 36 37 38 39 40 41 |
# File 'bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb', line 32 def <<(value) return self if value.nil? value = value.to_s value = Erubi.h(value) unless value.html_safe? @buffer << value self end |
#==(other) ⇒ Object
rubocop:enable Naming/BinaryOperatorParameterName
54 55 56 57 |
# File 'bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb', line 54 def ==(other) other.instance_of?(OutputBuffer) && @buffer == other.to_str end |
#html_safe ⇒ Object
63 |
# File 'bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb', line 63 def html_safe = to_s |
#html_safe? ⇒ Boolean
59 60 61 |
# File 'bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb', line 59 def html_safe? true end |
#initialize_copy(other) ⇒ Object
27 28 29 |
# File 'bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb', line 27 def initialize_copy(other) @buffer = other.to_str end |
#safe_concat(value) ⇒ Object Also known as: safe_append=
65 66 67 68 |
# File 'bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb', line 65 def safe_concat(value) @buffer << value self end |
#safe_expr_append=(val) ⇒ Object
71 72 73 74 75 |
# File 'bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb', line 71 def safe_expr_append=(val) return self if val.nil? # rubocop:disable Lint/ReturnInVoidContext safe_concat val.to_s end |
#to_s ⇒ Object
77 78 79 |
# File 'bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb', line 77 def to_s @buffer.html_safe end |
#to_str ⇒ Object
81 82 83 |
# File 'bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb', line 81 def to_str @buffer.dup end |
#|(value) ⇒ Object
Concatenation for <%== %> expressions, whose output is not escaped.
rubocop:disable Naming/BinaryOperatorParameterName
47 48 49 50 51 |
# File 'bridgetown-core/lib/bridgetown-core/converters/erb_templates.rb', line 47 def |(value) return self if value.nil? safe_concat(value.to_s) end |