lib/dry/view/controller.rb in dry-view-0.5.2 vs lib/dry/view/controller.rb in dry-view-0.5.3
- old
+ new
@@ -12,20 +12,24 @@
class Controller
UndefinedTemplateError = Class.new(StandardError)
DEFAULT_LAYOUTS_DIR = 'layouts'.freeze
DEFAULT_CONTEXT = Object.new.freeze
+ DEFAULT_RENDERER_OPTIONS = {default_encoding: 'utf-8'.freeze}.freeze
EMPTY_LOCALS = {}.freeze
include Dry::Equalizer(:config)
extend Dry::Configurable
setting :paths
setting :layout, false
setting :template
setting :default_format, :html
+ setting :renderer_options, DEFAULT_RENDERER_OPTIONS do |options|
+ DEFAULT_RENDERER_OPTIONS.merge(options.to_h).freeze
+ end
setting :context, DEFAULT_CONTEXT
setting :decorator, Decorator.new
attr_reader :config
attr_reader :layout_dir
@@ -47,10 +51,10 @@
end
# @api private
def self.renderer(format)
renderers.fetch(format) {
- renderers[format] = Renderer.new(paths, format: format)
+ renderers[format] = Renderer.new(paths, format: format, **config.renderer_options)
}
end
# @api private
def self.renderers