Sha256: a9976a4b4b55107aff5f31ca711f4219ab79c04192e34dc3bb31b4f6516004fe
Contents?: true
Size: 733 Bytes
Versions: 21
Compression:
Stored size: 733 Bytes
Contents
module Liquidscript module ICR class ::Array; def to_sexp; Sexp.new(self).output; end; end # @private class Sexp def initialize(compiler) @compiler = compiler @depth = 0 end def output out(@compiler).strip end private def out(v) if v.is_a?(Representable) || v.is_a?(Array) @depth += 1 body = ["\n", " " * @depth, "(", v.to_a.map {|d| out d }.join(' '), ")"].join @depth -= 1 body else body = v.to_s.gsub(/\"/, "\\\"") if body.include? " " "\"#{body}\"" else body end end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems