Template rendering helper.
(Currently only used by the SmtpParticipant, could prove useful for custom participants)
This module expects to find the ruote @context available (probably accessible thanks to the Ruote::LocalParticipant module, see Ruote::SmtpParticipant as an example).
Simply returns a pretty-printed view of the workitem
# File lib/ruote/part/template.rb, line 58 def render_default_template(workitem) workitem = workitem.to_h if workitem.respond_to?(:to_h) s = [] s << "workitem for #{workitem['participant_name']}" s << '' s << Rufus::Json.pretty_encode(workitem['fei']) s << '' workitem['fields'].keys.sort.each do |key| s << " - '#{key}' ==> #{Rufus::Json.encode(workitem['fields'][key])}" end s.join("\n") end
Do the rendering.
# File lib/ruote/part/template.rb, line 44 def render_template(template, flow_expression, workitem) template = (File.read(template) rescue nil) if is_a_file?(template) return render_default_template(workitem) unless template template = template.to_s workitem = workitem.to_h if workitem.respond_to?(:to_h) @context.dollar_sub.s(template, flow_expression, workitem) end
Generated with the Darkfish Rdoc Generator 2.