Sha256: 60ff7a8d39cbb4acce7323c2c4d0d8d3850568918c20d664874d8f1b34af8165
Contents?: true
Size: 652 Bytes
Versions: 12
Compression:
Stored size: 652 Bytes
Contents
require 'faml/filter_compilers/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
12 entries across 12 versions & 1 rubygems