liquid 5.3.0 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +16 -1
  3. data/README.md +2 -2
  4. data/lib/liquid/block_body.rb +4 -4
  5. data/lib/liquid/context.rb +6 -2
  6. data/lib/liquid/forloop_drop.rb +44 -1
  7. data/lib/liquid/locales/en.yml +6 -5
  8. data/lib/liquid/partial_cache.rb +3 -3
  9. data/lib/liquid/{static_registers.rb → registers.rb} +13 -10
  10. data/lib/liquid/standardfilters.rb +406 -57
  11. data/lib/liquid/strainer_factory.rb +4 -0
  12. data/lib/liquid/strainer_template.rb +4 -0
  13. data/lib/liquid/tablerowloop_drop.rb +58 -1
  14. data/lib/liquid/tags/assign.rb +12 -8
  15. data/lib/liquid/tags/break.rb +8 -0
  16. data/lib/liquid/tags/capture.rb +13 -10
  17. data/lib/liquid/tags/case.rb +21 -0
  18. data/lib/liquid/tags/comment.rb +13 -0
  19. data/lib/liquid/tags/continue.rb +8 -9
  20. data/lib/liquid/tags/cycle.rb +12 -11
  21. data/lib/liquid/tags/decrement.rb +16 -17
  22. data/lib/liquid/tags/echo.rb +16 -9
  23. data/lib/liquid/tags/for.rb +22 -43
  24. data/lib/liquid/tags/if.rb +11 -9
  25. data/lib/liquid/tags/include.rb +15 -13
  26. data/lib/liquid/tags/increment.rb +16 -14
  27. data/lib/liquid/tags/inline_comment.rb +43 -0
  28. data/lib/liquid/tags/raw.rb +11 -0
  29. data/lib/liquid/tags/render.rb +29 -4
  30. data/lib/liquid/tags/table_row.rb +22 -0
  31. data/lib/liquid/tags/unless.rb +15 -4
  32. data/lib/liquid/template.rb +2 -3
  33. data/lib/liquid/variable.rb +4 -4
  34. data/lib/liquid/variable_lookup.rb +10 -7
  35. data/lib/liquid/version.rb +1 -1
  36. data/lib/liquid.rb +2 -2
  37. metadata +7 -123
  38. data/lib/liquid/register.rb +0 -6
  39. data/test/fixtures/en_locale.yml +0 -9
  40. data/test/integration/assign_test.rb +0 -117
  41. data/test/integration/blank_test.rb +0 -109
  42. data/test/integration/block_test.rb +0 -58
  43. data/test/integration/capture_test.rb +0 -58
  44. data/test/integration/context_test.rb +0 -634
  45. data/test/integration/document_test.rb +0 -21
  46. data/test/integration/drop_test.rb +0 -257
  47. data/test/integration/error_handling_test.rb +0 -272
  48. data/test/integration/expression_test.rb +0 -46
  49. data/test/integration/filter_kwarg_test.rb +0 -24
  50. data/test/integration/filter_test.rb +0 -189
  51. data/test/integration/hash_ordering_test.rb +0 -25
  52. data/test/integration/output_test.rb +0 -125
  53. data/test/integration/parsing_quirks_test.rb +0 -134
  54. data/test/integration/profiler_test.rb +0 -240
  55. data/test/integration/security_test.rb +0 -89
  56. data/test/integration/standard_filter_test.rb +0 -925
  57. data/test/integration/tag/disableable_test.rb +0 -59
  58. data/test/integration/tag_test.rb +0 -45
  59. data/test/integration/tags/break_tag_test.rb +0 -17
  60. data/test/integration/tags/continue_tag_test.rb +0 -17
  61. data/test/integration/tags/echo_test.rb +0 -13
  62. data/test/integration/tags/for_tag_test.rb +0 -466
  63. data/test/integration/tags/if_else_tag_test.rb +0 -190
  64. data/test/integration/tags/include_tag_test.rb +0 -269
  65. data/test/integration/tags/increment_tag_test.rb +0 -25
  66. data/test/integration/tags/liquid_tag_test.rb +0 -116
  67. data/test/integration/tags/raw_tag_test.rb +0 -34
  68. data/test/integration/tags/render_tag_test.rb +0 -213
  69. data/test/integration/tags/standard_tag_test.rb +0 -303
  70. data/test/integration/tags/statements_test.rb +0 -113
  71. data/test/integration/tags/table_row_test.rb +0 -66
  72. data/test/integration/tags/unless_else_tag_test.rb +0 -28
  73. data/test/integration/template_test.rb +0 -340
  74. data/test/integration/trim_mode_test.rb +0 -563
  75. data/test/integration/variable_test.rb +0 -138
  76. data/test/test_helper.rb +0 -207
  77. data/test/unit/block_unit_test.rb +0 -53
  78. data/test/unit/condition_unit_test.rb +0 -181
  79. data/test/unit/file_system_unit_test.rb +0 -37
  80. data/test/unit/i18n_unit_test.rb +0 -39
  81. data/test/unit/lexer_unit_test.rb +0 -53
  82. data/test/unit/parse_tree_visitor_test.rb +0 -261
  83. data/test/unit/parser_unit_test.rb +0 -84
  84. data/test/unit/partial_cache_unit_test.rb +0 -128
  85. data/test/unit/regexp_unit_test.rb +0 -46
  86. data/test/unit/static_registers_unit_test.rb +0 -156
  87. data/test/unit/strainer_factory_unit_test.rb +0 -101
  88. data/test/unit/strainer_template_unit_test.rb +0 -82
  89. data/test/unit/tag_unit_test.rb +0 -23
  90. data/test/unit/tags/case_tag_unit_test.rb +0 -12
  91. data/test/unit/tags/for_tag_unit_test.rb +0 -15
  92. data/test/unit/tags/if_tag_unit_test.rb +0 -10
  93. data/test/unit/template_factory_unit_test.rb +0 -12
  94. data/test/unit/template_unit_test.rb +0 -87
  95. data/test/unit/tokenizer_unit_test.rb +0 -62
  96. data/test/unit/variable_unit_test.rb +0 -164
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class BlockTest < Minitest::Test
6
- include Liquid
7
-
8
- def test_unexpected_end_tag
9
- exc = assert_raises(SyntaxError) do
10
- Template.parse("{% if true %}{% endunless %}")
11
- end
12
- assert_equal(exc.message, "Liquid syntax error: 'endunless' is not a valid delimiter for if tags. use endif")
13
- end
14
-
15
- def test_with_custom_tag
16
- with_custom_tag('testtag', Block) do
17
- assert(Liquid::Template.parse("{% testtag %} {% endtesttag %}"))
18
- end
19
- end
20
-
21
- def test_custom_block_tags_have_a_default_render_to_output_buffer_method_for_backwards_compatibility
22
- klass1 = Class.new(Block) do
23
- def render(*)
24
- 'hello'
25
- end
26
- end
27
-
28
- with_custom_tag('blabla', klass1) do
29
- template = Liquid::Template.parse("{% blabla %} bla {% endblabla %}")
30
-
31
- assert_equal('hello', template.render)
32
-
33
- buf = +''
34
- output = template.render({}, output: buf)
35
- assert_equal('hello', output)
36
- assert_equal('hello', buf)
37
- assert_equal(buf.object_id, output.object_id)
38
- end
39
-
40
- klass2 = Class.new(klass1) do
41
- def render(*)
42
- 'foo' + super + 'bar'
43
- end
44
- end
45
-
46
- with_custom_tag('blabla', klass2) do
47
- template = Liquid::Template.parse("{% blabla %} foo {% endblabla %}")
48
-
49
- assert_equal('foohellobar', template.render)
50
-
51
- buf = +''
52
- output = template.render({}, output: buf)
53
- assert_equal('foohellobar', output)
54
- assert_equal('foohellobar', buf)
55
- assert_equal(buf.object_id, output.object_id)
56
- end
57
- end
58
- end
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- class CaptureTest < Minitest::Test
6
- include Liquid
7
-
8
- def test_captures_block_content_in_variable
9
- assert_template_result("test string", "{% capture 'var' %}test string{% endcapture %}{{var}}", {})
10
- end
11
-
12
- def test_capture_with_hyphen_in_variable_name
13
- template_source = <<-END_TEMPLATE
14
- {% capture this-thing %}Print this-thing{% endcapture %}
15
- {{ this-thing }}
16
- END_TEMPLATE
17
- template = Template.parse(template_source)
18
- rendered = template.render!
19
- assert_equal("Print this-thing", rendered.strip)
20
- end
21
-
22
- def test_capture_to_variable_from_outer_scope_if_existing
23
- template_source = <<-END_TEMPLATE
24
- {% assign var = '' %}
25
- {% if true %}
26
- {% capture var %}first-block-string{% endcapture %}
27
- {% endif %}
28
- {% if true %}
29
- {% capture var %}test-string{% endcapture %}
30
- {% endif %}
31
- {{var}}
32
- END_TEMPLATE
33
- template = Template.parse(template_source)
34
- rendered = template.render!
35
- assert_equal("test-string", rendered.gsub(/\s/, ''))
36
- end
37
-
38
- def test_assigning_from_capture
39
- template_source = <<-END_TEMPLATE
40
- {% assign first = '' %}
41
- {% assign second = '' %}
42
- {% for number in (1..3) %}
43
- {% capture first %}{{number}}{% endcapture %}
44
- {% assign second = first %}
45
- {% endfor %}
46
- {{ first }}-{{ second }}
47
- END_TEMPLATE
48
- template = Template.parse(template_source)
49
- rendered = template.render!
50
- assert_equal("3-3", rendered.gsub(/\s/, ''))
51
- end
52
-
53
- def test_increment_assign_score_by_bytes_not_characters
54
- t = Template.parse("{% capture foo %}すごい{% endcapture %}")
55
- t.render!
56
- assert_equal(9, t.resource_limits.assign_score)
57
- end
58
- end