Sha256: 6076fc82b8c373559d4e6c89e5070c0fd46ea513e1f9a98f6c170dffd8e1ffe0
Contents?: true
Size: 1.1 KB
Versions: 11
Compression:
Stored size: 1.1 KB
Contents
require 'temple' require 'tilt' require_relative 'base' module Faml module FilterCompilers class TiltBase < Base include Temple::Utils def self.render_with_tilt(name, source, indent_width: 0) text = ::Tilt["t.#{name}"].new { source }.render indent = ' ' * indent_width "#{indent}#{text.rstrip.gsub("\n", "\n#{indent}")}" end protected def compile_with_tilt(temple, name, ast, indent_width: 0) source = ast.texts.join("\n") if TextCompiler.contains_interpolation?(source) text_temple = [:multi] compile_texts(text_temple, ast.lineno, ast.texts) sym = unique_name temple << [:capture, sym, text_temple] temple << [:dynamic, "::Faml::FilterCompilers::TiltBase.render_with_tilt(#{name.inspect}, #{sym}, indent_width: #{indent_width})"] else compiled = self.class.render_with_tilt(name, source, indent_width: indent_width) temple << [:static, compiled] temple.concat([[:newline]] * (ast.texts.size - 1)) end temple end end end end
Version data entries
11 entries across 11 versions & 1 rubygems