Dylan Thacker-Smith
e20df18eca
[WIP] Add support for migrating liquid code away from several lax parse quirks
...
It transforms liquid code to equivalently parsed code, that doesn't depend
on lax parsing quirks.
Note that this transformation can hide the intent of the original code, so
it is best to review the changes, since removed syntax often would indicate
a bug in the original liquid code.
2022-11-16 17:35:29 -05:00
Dylan Thacker-Smith and GitHub
86605016e1
Add Liquid::VariableLookup#lookup_command? to expose this parse node state ( #1583 )
2022-07-04 14:42:05 -04:00
Watson
1667c1180e
Use start_with? and end_with? to detect SQUARE_BRAKET
...
## Test code
```ruby
require 'benchmark/ips'
SQUARE_BRACKETED = /\A\[(.*)\]\z/m
markup = "[product.catchall]"
Benchmark.ips do |x|
x.report("SQUARE_BRACKETED") {
if markup =~ SQUARE_BRACKETED
Regexp.last_match(1)
end
}
x.report("start/end_with?") {
if markup&.start_with?('[') && markup&.end_with?(']')
markup[1..-2]
end
}
x.compare!
end
```
## Result
```
Warming up --------------------------------------
SQUARE_BRACKETED 261.300k i/100ms
start/end_with? 548.813k i/100ms
Calculating -------------------------------------
SQUARE_BRACKETED 2.632M (± 0.6%) i/s - 13.326M in 5.064085s
start/end_with? 5.471M (± 0.5%) i/s - 27.441M in 5.015770s
Comparison:
start/end_with?: 5470994.1 i/s
SQUARE_BRACKETED: 2631642.3 i/s - 2.08x (± 0.00) slower
```
2022-03-12 18:14:16 +09:00
Michael Go
e361a4d53c
introduce to_liquid_value on variable look and conditional statements
2021-05-26 17:27:18 -03:00
Alessandro Diogo Brückheimer and Mike Angell
e83b1e4159
Add ForceEqualSignAlignment to .rubocop.yml ( #1190 )
...
* Add ForceEqualSignAlignment to .rubocop.yml
* Revert ForceEqualSignAlignment cop
* Update method alignment
* Undo addition of whitespace to improve readability
* Fix missing alignment
2019-10-21 21:18:48 +10:00
0d26f05bb8
Enabled frozen string literals ( #1154 )
...
* Enabled frozen string literals
* Update rubocop config
* Prefer string interpolation in simple cases
Co-Authored-By: Dylan Thacker-Smith <[email protected] >
2019-09-18 13:19:45 +10:00
Mike Angell
799da202df
Apply simple rubocop fixes
2019-08-31 21:58:33 +10:00
Ashwin Maroli and Justin Li
f59f6dea83
Fix simple RuboCop offenses and update TODO file ( #1062 )
...
* Fix Layout/EmptyLineAfterMagicComment offense
* Fix Layout/ExtraSpacing offense
* Fix Layout/ClosingParenthesisIndentation offenses
* Fix Style/MutableConstant offense
* Fix Style/UnneededInterpolation offenses
* Fix Style/RedundantParentheses offenses
* Update TODO config for RuboCop
* Add executable bit to test/test_helper.rb
ref: https://travis-ci.org/Shopify/liquid/jobs/488169512#L578
2019-02-22 12:32:56 -05:00
Stephen Paul Weber
7d13d88258
s/Traversal/ParseTreeVisitor
2018-10-18 09:38:33 -04:00
Stephen Paul Weber
c11fc656cf
Colocate Traversal classes with classes they traverse
...
This puts all knowledge of the traversal in the same file, and removes
the need for a CASES registry.
2018-10-18 09:37:48 -04:00
Ivan Kuznetsov
dadd9b4dd2
Add strict_variables/strict_filters render options to check for undefined variables and filters
2016-02-03 10:49:33 +07:00
Florian Weingarten
5919626da4
Rename 'has_key?' and 'has_interrupt?'
2015-06-04 13:14:46 -04:00
Florian Weingarten
3372ca8136
Rubocop
2015-05-14 14:37:18 +00:00
Justin Li
f1f3f57647
Remove command_lookups reader
2015-04-21 00:25:51 -04:00
Justin Li
e5dd63e1fc
Expose name, lookups, and command flags from VariableLookup
2015-04-20 17:36:04 -04:00
Justin Li
a206c8301d
Fix test leaking error_mode, fix equality check for VariableLookup
2014-10-22 15:40:41 -04:00
Dylan Thacker-Smith
f387508666
Parse expressions in Liquid::Variable#parse.
2014-10-08 21:06:59 -04:00
Dylan Thacker-Smith
2aa9bbbac2
Separate expression parsing and rendering from Context#resolve.
2014-08-11 14:15:58 -07:00