lib/openwfe/expressions/fe_value.rb in openwferu-0.9.15 vs lib/openwfe/expressions/fe_value.rb in openwferu-0.9.16

- old
+ new

@@ -63,11 +63,11 @@ private def lookup (name_array, workitem) name_array.each do |n| - v = lookup_attribute(n, workitem) + v = lookup_string_attribute n, workitem return v if v end nil end @@ -86,47 +86,60 @@ # # 'set' expressions may be placed outside of a process-definition body, # they will be evaluated sequentially before the body gets applied # (executed). # - # Since OpenWFEru 0.9.14, shorter attributes are OK : + # Shorter attributes are OK : # # <set f="price" val="CHF 12.00" /> # <set v="/stage" val="3" /> # <set v="/stage" field-val="f_stage" /> # <set f="stamp" val="${r:Time.now.to_i}" /> # # set :f => "price", :val => "USD 12.50" # set :v => "toto", :val => "elvis" # + # In case you need the value not to be evaluated if it contains + # dollar expressions, you can do + # + # set :v => "v0", :val => "my ${template} thing", :escape => true + # + # to prevent evaluation (i.e. to escape). + # class SetValueExpression < FlowExpression include ValueMixin is_definition names :set def apply (workitem) + escape = lookup_boolean_attribute('escape', workitem, false) + if @children.length < 1 - workitem.attributes[FIELD_RESULT] = lookup_value(workitem) - reply(workitem) + + workitem.attributes[FIELD_RESULT] = \ + lookup_value(workitem, :escape => escape) + + reply workitem return end child = @children[0] - if child.kind_of? OpenWFE::FlowExpressionId - handle_child(child, workitem) + if child.kind_of?(OpenWFE::FlowExpressionId) + + handle_child child, workitem return end - #workitem.attributes[FIELD_RESULT] = child.to_s - workitem.attributes[FIELD_RESULT] = fetch_text_content(workitem) + workitem.attributes[FIELD_RESULT] = \ + fetch_text_content(workitem, escape) - reply(workitem) + reply workitem end def reply (workitem) vkey = lookup_variable_attribute(workitem) @@ -149,17 +162,24 @@ protected def handle_child (child, workitem) - child, _fei = get_expression_pool().fetch(child) + raw_child, _fei = get_expression_pool.fetch(child) - if child.is_definition? - fei = get_expression_pool().evaluate(child, workitem) - workitem.attributes[FIELD_RESULT] = fei - reply(workitem) + if raw_child.is_definition? + + #body_fei = get_expression_pool.evaluate child, workitem + #workitem.attributes[FIELD_RESULT] = body_fei + + workitem.attributes[FIELD_RESULT] = raw_child + # + # storing the child raw expression + + reply workitem else - get_expression_pool().apply(child, workitem) + + get_expression_pool.apply raw_child, workitem end end end #