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 52 def create_template(opts, template_opts) 53 return super if opts[:template_block] 54 55 path = File.expand_path(opts[:path]) 56 compiled_path = nil 57 (self.opts[:render_coverage_strip_paths] || render_opts[:allowed_paths]).each do |dir| 58 if path.start_with?(dir + '/') 59 compiled_path = File.join(self.opts[:render_coverage_dir], path[dir.length+1, 10000000].gsub('/', '-')) 60 break 61 end 62 end 63 64 # For Tilt 2.6+, when using :scope_class and fixed locals, must provide 65 # compiled path as option, since compilation happens during initalization 66 # in that case. This option should be ignored if the template does not 67 # support it, but some template class may break if the option is not 68 # handled, so for compatibility, only set the method if Tilt::Template 69 # will handle it. 70 if compiled_path && Tilt::Template.method_defined?(:fixed_locals?) 71 template_opts = template_opts.dup 72 template_opts[:compiled_path] = compiled_path 73 compiled_path = nil 74 end 75 76 template = super 77 78 # Set compiled path for template when using older tilt versions. 79 # :nocov: 80 template.compiled_path = compiled_path if compiled_path 81 # :nocov: 82 83 template 84 end