class TextLiteral

A long block of text literal, with variable templating

Public Instance Methods

to_html(context) click to toggle source
# File lib/emerald/nodes/text_literal.rb, line 9
def to_html(context)
  body
    .elements
    .map do |element|
      if element.is_a?(Variable)
        element.to_html(context)
      else
        unescape element.text_value
      end
    end
    .join('')
    .rstrip
end
unescape(text) click to toggle source
# File lib/emerald/nodes/text_literal.rb, line 23
def unescape(text)
  text.gsub(/\\(.)/, '\1')
end