Sha256: 83b6683b27dc51001f8566c04eba7b1909b94329499479e73f82d4d6c7c92843
Contents?: true
Size: 709 Bytes
Versions: 7
Compression:
Stored size: 709 Bytes
Contents
require 'fast_haml/filter_compilers/base' module FastHaml module FilterCompilers class Preserve < Base include Temple::Utils def compile(texts) temple = [:multi] texts.each do |text| temple << text_compiler.compile(text) unless texts.last.equal?(text) temple << [:static, "\n"] end temple << [:newline] end sym = unique_name [:multi, [:capture, sym, temple], [:dynamic, "::FastHaml::FilterCompilers::Preserve.preserve(#{sym})"], ] end def self.preserve(str) str.gsub("\n", '
') end end register(:preserve, Preserve) end end
Version data entries
7 entries across 7 versions & 1 rubygems