class Macros4Cuke::Templating::Placeholder

Class used internally by the template engine. Represents a named placeholder in a template, that is, a name placed between <..> in the template. At rendition, a placeholder is replaced by the text value that is associated with it.

Public Instance Methods

render(aContextObject, theLocals) click to toggle source

Render the placeholder given the passed arguments. 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.
# File lib/macros4cuke/templating/placeholder.rb, line 23
def render(aContextObject, theLocals)
  actual_value = retrieve_value_from(aContextObject, theLocals)

  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