lib/clamsy/template_open_doc.rb in clamsy-0.0.4 vs lib/clamsy/template_open_doc.rb in clamsy-0.0.5

- old
+ new

@@ -18,14 +18,20 @@ file_must_exist!(@template_doc = template_doc) initialize_template_workers end def render(context) - File.copy(@template_doc, (file = tmp_file).path) + File.copy(@template_doc, (file = tmp_doc(context)).path) OpenDoc.new(file, @template_workers, context).transform end private + + def tmp_doc(context) + @template_doc_suffix ||= ".#{@template_doc.to_s.split('.').last}" + uid = Digest::MD5.hexdigest(Time.now.to_s + context.to_s) + tmp_file([uid, @template_doc_suffix]) + end def initialize_template_workers begin OpenDoc.per_content_entry(@template_doc) \ {|@entry| (@template_workers_cache ||= {})[@entry.to_s] = template_worker }