Module: XRB::Markup

Defined in:
lib/xrb/markup.rb,
ext/xrb/xrb.c

Overview

Provides the default markup rendering protocol, escaping object string representations.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.append(output, value) ⇒ Object

Append a value to an output buffer using its markup representation.



22
23
24
# File 'lib/xrb/markup.rb', line 22

def self.append(output, value)
  value.append_markup(output)
end

.raw(string) ⇒ Object

Wrap a string as markup without escaping it.



14
15
16
# File 'lib/xrb/markup.rb', line 14

def self.raw(string)
  MarkupString.raw(string)
end

Instance Method Details

#append_markup(output) ⇒ Object

Append self to the output buffer efficiently, escaping special characters.



29
30
31
# File 'lib/xrb/markup.rb', line 29

def append_markup(output)
  output << ::CGI.escape_html(self.to_s)
end

#build_markup(builder) ⇒ Object

Append the escaped string representation of the receiver using a builder.



36
37
38
# File 'lib/xrb/markup.rb', line 36

def build_markup(builder)
  append_markup(builder.output)
end