Sha256: ee1813ac24ee416c906d6a107fa0f6ba0d7e1ec12658768efe65d285f71796c7
Contents?: true
Size: 667 Bytes
Versions: 9
Compression:
Stored size: 667 Bytes
Contents
# frozen-string-literal: true require_relative 'base' module Faml module FilterCompilers class Preserve < Base include Temple::Utils def compile(ast) temple = [:multi, [:newline]] # I don't know why only :preserve filter keeps the last empty lines. compile_texts(temple, ast.lineno, ast.texts, keep_last_empty_lines: true) sym = unique_name [:multi, [:capture, sym, temple], [:dynamic, "::Faml::FilterCompilers::Preserve.preserve(#{sym})"], ] end def self.preserve(str) str.gsub("\n", '
') end end register(:preserve, Preserve) end end
Version data entries
9 entries across 9 versions & 1 rubygems