lib/ruote/part/template.rb in ruote-2.1.10 vs lib/ruote/part/template.rb in ruote-2.1.11
- old
+ new
@@ -21,33 +21,38 @@
#
# Made in Japan.
#++
require 'rufus/json'
-require 'ruote/util/dollar'
module Ruote
#
# 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).
+ #
module TemplateMixin
+ # Do the rendering.
+ #
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)
- Ruote.dosub(template, flow_expression, workitem)
+ @context.dollar_sub.s(template, flow_expression, workitem)
end
# Simply returns a pretty-printed view of the workitem
#
def render_default_template (workitem)
@@ -55,10 +60,10 @@
workitem = workitem.to_h if workitem.respond_to?(:to_h)
s = []
s << "workitem for #{workitem['participant_name']}"
s << ''
- s << Rufus::Json.encode(workitem['fei'])
+ 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")