lib/fdoc/presenters/base_presenter.rb in fdoc-0.3.1 vs lib/fdoc/presenters/base_presenter.rb in fdoc-0.3.2

- old
+ new

@@ -13,14 +13,11 @@ def initialize(options = {}) @options = options end def render_erb(erb_name, binding = get_binding) - template_path = File.join(options[:template_directory], erb_name) - if !File.exists? template_path - template_path = File.join(File.dirname(__FILE__), "../templates", erb_name) - end + template_path = path_for_template(erb_name) template = ERB.new(File.read(template_path), nil, '-') template.result(binding) end def render_markdown(markdown_str) @@ -59,7 +56,18 @@ <a href="##{anchor_slug}" class="anchor"> #{content} </a> </#{tag}> EOS + end + + protected + + def path_for_template(filename) + template_dir = options[:template_directory] + template_path = File.join(template_dir, filename) if template_dir + if template_path.nil? || !File.exists?(template_path) + template_path = File.join(File.dirname(__FILE__), "../templates", filename) + end + template_path end end