File: filter_kwarg_test.rb

package info (click to toggle)
ruby-liquid 5.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,176 kB
  • sloc: ruby: 10,561; makefile: 6
file content (24 lines) | stat: -rw-r--r-- 543 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

require 'test_helper'

class FilterKwargTest < Minitest::Test
  module KwargFilter
    def html_tag(_tag, attributes)
      attributes
        .map { |key, value| "#{key}='#{value}'" }
        .join(' ')
    end
  end

  include Liquid

  def test_can_parse_data_kwargs
    with_global_filter(KwargFilter) do
      assert_equal(
        "data-src='src' data-widths='100, 200'",
        Template.parse("{{ 'img' | html_tag: data-src: 'src', data-widths: '100, 200' }}").render(nil, nil)
      )
    end
  end
end