Method: Erector::Convenience#join

Defined in:
lib/erector/convenience.rb

#join(array, separator) ⇒ Object

Emits the result of joining the elements in array with the separator. The array elements and separator can be Erector::Widget objects, which are rendered, or strings, which are html-escaped and output.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/erector/convenience.rb', line 26

def join(array, separator)
  first = true
  array.each do |item|
    if !first
      if separator.is_a? Widget
        widget separator
      else
        text separator
      end
    end
    first = false
    if item.is_a? Widget
      widget item
    else
      text item
    end
  end
end