liquid 5.3.0 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +16 -1
- data/README.md +2 -2
- data/lib/liquid/block_body.rb +4 -4
- data/lib/liquid/context.rb +6 -2
- data/lib/liquid/forloop_drop.rb +44 -1
- data/lib/liquid/locales/en.yml +6 -5
- data/lib/liquid/partial_cache.rb +3 -3
- data/lib/liquid/{static_registers.rb → registers.rb} +13 -10
- data/lib/liquid/standardfilters.rb +406 -57
- data/lib/liquid/strainer_factory.rb +4 -0
- data/lib/liquid/strainer_template.rb +4 -0
- data/lib/liquid/tablerowloop_drop.rb +58 -1
- data/lib/liquid/tags/assign.rb +12 -8
- data/lib/liquid/tags/break.rb +8 -0
- data/lib/liquid/tags/capture.rb +13 -10
- data/lib/liquid/tags/case.rb +21 -0
- data/lib/liquid/tags/comment.rb +13 -0
- data/lib/liquid/tags/continue.rb +8 -9
- data/lib/liquid/tags/cycle.rb +12 -11
- data/lib/liquid/tags/decrement.rb +16 -17
- data/lib/liquid/tags/echo.rb +16 -9
- data/lib/liquid/tags/for.rb +22 -43
- data/lib/liquid/tags/if.rb +11 -9
- data/lib/liquid/tags/include.rb +15 -13
- data/lib/liquid/tags/increment.rb +16 -14
- data/lib/liquid/tags/inline_comment.rb +43 -0
- data/lib/liquid/tags/raw.rb +11 -0
- data/lib/liquid/tags/render.rb +29 -4
- data/lib/liquid/tags/table_row.rb +22 -0
- data/lib/liquid/tags/unless.rb +15 -4
- data/lib/liquid/template.rb +2 -3
- data/lib/liquid/variable.rb +4 -4
- data/lib/liquid/variable_lookup.rb +10 -7
- data/lib/liquid/version.rb +1 -1
- data/lib/liquid.rb +2 -2
- metadata +7 -123
- data/lib/liquid/register.rb +0 -6
- data/test/fixtures/en_locale.yml +0 -9
- data/test/integration/assign_test.rb +0 -117
- data/test/integration/blank_test.rb +0 -109
- data/test/integration/block_test.rb +0 -58
- data/test/integration/capture_test.rb +0 -58
- data/test/integration/context_test.rb +0 -634
- data/test/integration/document_test.rb +0 -21
- data/test/integration/drop_test.rb +0 -257
- data/test/integration/error_handling_test.rb +0 -272
- data/test/integration/expression_test.rb +0 -46
- data/test/integration/filter_kwarg_test.rb +0 -24
- data/test/integration/filter_test.rb +0 -189
- data/test/integration/hash_ordering_test.rb +0 -25
- data/test/integration/output_test.rb +0 -125
- data/test/integration/parsing_quirks_test.rb +0 -134
- data/test/integration/profiler_test.rb +0 -240
- data/test/integration/security_test.rb +0 -89
- data/test/integration/standard_filter_test.rb +0 -925
- data/test/integration/tag/disableable_test.rb +0 -59
- data/test/integration/tag_test.rb +0 -45
- data/test/integration/tags/break_tag_test.rb +0 -17
- data/test/integration/tags/continue_tag_test.rb +0 -17
- data/test/integration/tags/echo_test.rb +0 -13
- data/test/integration/tags/for_tag_test.rb +0 -466
- data/test/integration/tags/if_else_tag_test.rb +0 -190
- data/test/integration/tags/include_tag_test.rb +0 -269
- data/test/integration/tags/increment_tag_test.rb +0 -25
- data/test/integration/tags/liquid_tag_test.rb +0 -116
- data/test/integration/tags/raw_tag_test.rb +0 -34
- data/test/integration/tags/render_tag_test.rb +0 -213
- data/test/integration/tags/standard_tag_test.rb +0 -303
- data/test/integration/tags/statements_test.rb +0 -113
- data/test/integration/tags/table_row_test.rb +0 -66
- data/test/integration/tags/unless_else_tag_test.rb +0 -28
- data/test/integration/template_test.rb +0 -340
- data/test/integration/trim_mode_test.rb +0 -563
- data/test/integration/variable_test.rb +0 -138
- data/test/test_helper.rb +0 -207
- data/test/unit/block_unit_test.rb +0 -53
- data/test/unit/condition_unit_test.rb +0 -181
- data/test/unit/file_system_unit_test.rb +0 -37
- data/test/unit/i18n_unit_test.rb +0 -39
- data/test/unit/lexer_unit_test.rb +0 -53
- data/test/unit/parse_tree_visitor_test.rb +0 -261
- data/test/unit/parser_unit_test.rb +0 -84
- data/test/unit/partial_cache_unit_test.rb +0 -128
- data/test/unit/regexp_unit_test.rb +0 -46
- data/test/unit/static_registers_unit_test.rb +0 -156
- data/test/unit/strainer_factory_unit_test.rb +0 -101
- data/test/unit/strainer_template_unit_test.rb +0 -82
- data/test/unit/tag_unit_test.rb +0 -23
- data/test/unit/tags/case_tag_unit_test.rb +0 -12
- data/test/unit/tags/for_tag_unit_test.rb +0 -15
- data/test/unit/tags/if_tag_unit_test.rb +0 -10
- data/test/unit/template_factory_unit_test.rb +0 -12
- data/test/unit/template_unit_test.rb +0 -87
- data/test/unit/tokenizer_unit_test.rb +0 -62
- 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
|