lib/dry/view/renderer.rb in dry-view-0.5.2 vs lib/dry/view/renderer.rb in dry-view-0.5.3

- old
+ new

@@ -5,23 +5,24 @@ module View class Renderer PARTIAL_PREFIX = "_".freeze PATH_DELIMITER = "/".freeze - include Dry::Equalizer(:paths, :format) + include Dry::Equalizer(:paths, :format, :options) TemplateNotFoundError = Class.new(StandardError) - attr_reader :paths, :format, :engine, :tilts + attr_reader :paths, :format, :options, :tilts def self.tilts @__engines__ ||= {} end - def initialize(paths, format:) + def initialize(paths, format:, **options) @paths = paths @format = format + @options = options @tilts = self.class.tilts end def template(name, scope, &block) path = lookup(name) @@ -59,13 +60,12 @@ def name_for_partial(name) name_segments = name.to_s.split(PATH_DELIMITER) partial_name = name_segments[0..-2].push("#{PARTIAL_PREFIX}#{name_segments[-1]}").join(PATH_DELIMITER) end - # TODO: make default_encoding configurable def tilt(path) tilts.fetch(path) { - tilts[path] = Tilt.new(path, nil, default_encoding: "utf-8") + tilts[path] = Tilt.new(path, nil, **options) } end end end end