Sha256: 5cab3fb8175d2cd52ce6c80756974fc7c6ca053242315530b8356980a4b169c3

Contents?: true

Size: 488 Bytes

Versions: 1

Compression:

Stored size: 488 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'treetop'
require_relative 'node'

# A long block of text literal, with variable templating
class TextLiteral < Node
  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

  def unescape(text)
    text.gsub(/\\(.)/, '\1')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
emerald-lang-1.0.0 lib/emerald/nodes/text_literal.rb