Sha256: 4011416045d612b2f72d66cc80c40f7a747cfa756a38893366b2ce6b6673b552

Contents?: true

Size: 393 Bytes

Versions: 7

Compression:

Stored size: 393 Bytes

Contents

# frozen_string_literal: true

module ArrayWrapFilter
  # Wraps an object into an array if it is not already an array.
  #
  # Example:
  #   <div class="summary">{%assign res = payload.test['MESSAGE']['ITEM'] | array_wrap %}{%for item in res %}{{item['PN']['$']}}{%endfor%}</div>
  ##
  def array_wrap(input)
    Array.wrap(input)
  end
end

Liquid::Template.register_filter(ArrayWrapFilter)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
liquidum-1.2.1 lib/liquidum/liquid/filters/array_wrap_filter.rb
liquidum-1.2.0 lib/liquidum/liquid/filters/array_wrap_filter.rb
liquidum-1.1.2 lib/liquidum/liquid/filters/array_wrap_filter.rb
liquidum-1.1.1 lib/liquidum/liquid/filters/array_wrap_filter.rb
liquidum-1.1.0 lib/liquidum/liquid/filters/array_wrap_filter.rb
liquidum-1.0.22 lib/liquidum/liquid/filters/array_wrap_filter.rb
liquidum-1.0.17 lib/liquidum/liquid/filters/array_wrap_filter.rb