lib/macros4cuke/templating/engine.rb in macros4cuke-0.2.17 vs lib/macros4cuke/templating/engine.rb in macros4cuke-0.2.18
- old
+ new
@@ -54,15 +54,28 @@
# This method has the same signature as the {Engine#render} method.
# @return [String] The text value assigned to the placeholder.
# Returns an empty string when no value is assigned to the placeholder.
def render(aContextObject, theLocals)
actual_value = theLocals[name]
- if actual_value.nil?
- actual_value = aContextObject.send(name.to_sym) if aContextObject.respond_to?(name.to_sym)
- actual_value = '' if actual_value.nil?
+ if actual_value.nil? && aContextObject.respond_to?(name.to_sym)
+ actual_value = aContextObject.send(name.to_sym)
end
- return actual_value.is_a?(String) ? actual_value : actual_value.to_s
+ result = case actual_value
+ when NilClass
+ ''
+
+ when Array
+ # TODO: Move away from hard-coded separator.
+ actual_value.join("<br/>")
+
+ when String
+ actual_value
+ else
+ actual_value.to_s()
+ end
+
+ return result
end
end # class
\ No newline at end of file