Public Instance methods
create_template(opts, template_opts)
Set a compiled path on the created template, if the path for the template is in one of the allowed_views.
[show source]
# File lib/roda/plugins/render_coverage.rb 55 def create_template(opts, template_opts) 56 return super if opts[:template_block] 57 58 path = File.expand_path(opts[:path]) 59 compiled_path = nil 60 (render_coverage_strip_paths || render_opts[:allowed_paths]).each do |dir| 61 dir += "/" unless dir.end_with?("/") 62 if path.start_with?(dir) 63 compiled_path = File.join(render_coverage_dir, path[dir.length, 10000000].tr('/', '-')) 64 break 65 end 66 end 67 68 # For Tilt 2.6+, when using :scope_class and fixed locals, must provide 69 # compiled path as option, since compilation happens during initalization 70 # in that case. This option should be ignored if the template does not 71 # support it, but some template class may break if the option is not 72 # handled, so for compatibility, only set the method if Tilt::Template 73 # will handle it. 74 if compiled_path && Tilt::Template.method_defined?(:fixed_locals?) 75 template_opts = template_opts.dup 76 template_opts[:compiled_path] = compiled_path 77 compiled_path = nil 78 end 79 80 template = super 81 82 # Set compiled path for template when using older tilt versions. 83 # simplecov:disable 84 template.compiled_path = compiled_path if compiled_path 85 # simplecov:enable 86 87 template 88 end