lib/xml/kit/template.rb in xml-kit-0.1.10 vs lib/xml/kit/template.rb in xml-kit-0.1.11

- old
+ new

@@ -1,8 +1,10 @@ module Xml module Kit class Template + TEMPLATES_DIR=Pathname.new(File.join(__dir__, "templates/" )) + attr_reader :target def initialize(target) @target = target end @@ -16,17 +18,18 @@ private def template_path return target.template_path if target.respond_to?(:template_path) + TEMPLATES_DIR.join(template_name) + end - root_path = File.expand_path(File.dirname(__FILE__)) - template_name = "#{target.class.name.split("::").last.underscore}.builder" - File.join(root_path, "templates/", template_name) + def template_name + "#{target.class.name.split("::").last.underscore}.builder" end def template - Tilt.new(template_path) + @template ||= Tilt.new(template_path.to_s) end end end end