Merge pull request #1354 from Shopify/pz-instrument-for-offset-continue

Instrument usage of offset:continue in for loops
This commit is contained in:
Peter Zhu
2020-11-12 14:14:09 -05:00
committed by GitHub
2 changed files with 11 additions and 0 deletions

View File

@@ -198,6 +198,7 @@ module Liquid
case key
when 'offset'
@from = if expr == 'continue'
Usage.increment('for_offset_continue')
:continue
else
parse_expression(expr)

View File

@@ -437,4 +437,14 @@ HERE
assert(context.registers[:for_stack].empty?)
end
def test_instrument_for_offset_continue
assert_usage_increment('for_offset_continue') do
Template.parse('{% for item in items offset:continue %}{{item}}{% endfor %}')
end
assert_usage_increment('for_offset_continue', times: 0) do
Template.parse('{% for item in items offset:2 %}{{item}}{% endfor %}')
end
end
end