1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
# frozen_string_literal: true
require_relative 'template'
module Tilt
# Superclass used for pipeline templates. Should not be used directly.
class Pipeline < Template
def prepare
@pipeline = self.class::TEMPLATES.inject(proc{|*| data}) do |data, (klass, ext, options)|
proc do |s,l,&sb|
options = options
if ext_opts = @options[ext]
options = options.merge(ext_opts)
end
klass.new(file, line, options, &proc{|*| data.call(s, l, &sb)}).render(s, l, &sb)
end
end
end
def evaluate(scope, locals, &block)
@pipeline.call(scope, locals, &block)
end
end
end
|