Module: Roda::RodaPlugins::RenderCoverage::ClassMethods

Defined in:
lib/roda/plugins/render_coverage.rb

Instance Method Summary collapse

Instance Method Details

#create_template(opts, template_opts) ⇒ Object

Set a compiled path on the created template, if the path for the template is in one of the allowed_views.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/roda/plugins/render_coverage.rb', line 52

def create_template(opts, template_opts)
  template = super
  return template if opts[:template_block]

  path = File.expand_path(opts[:path])
  (self.opts[:render_coverage_strip_paths] || render_opts[:allowed_paths]).each do |dir|
    if path.start_with?(dir + '/')
      template.compiled_path = File.join(self.opts[:render_coverage_dir], path[dir.length+1, 10000000].gsub('/', '-'))
      break
    end
  end

  template
end