Sha256: b81fe835ddd126e58d1b91b4d88f070793d366089e20e46db175c46d816b927b
Contents?: true
Size: 983 Bytes
Versions: 1
Compression:
Stored size: 983 Bytes
Contents
require 'fast_haml/text_compiler' module FastHaml module FilterCompilers class Base def need_newline? true end protected def compile_texts(temple, texts, tab_width: 0, keep_last_empty_lines: false) tabs = ' ' * tab_width n = 0 unless keep_last_empty_lines texts, n = strip_last_empty_lines(texts) end texts.each do |text| temple << [:static, tabs] << text_compiler.compile(text) unless texts.last.equal?(text) temple << [:static, "\n"] << [:newline] end end temple.concat([[:newline]] * n) nil end def text_compiler @text_compiler ||= TextCompiler.new(escape_html: false) end def strip_last_empty_lines(texts) n = 0 texts = texts.dup while texts.last && texts.last.empty? n += 1 texts.pop end [texts, n] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fast_haml-0.1.10 | lib/fast_haml/filter_compilers/base.rb |