Jake Olney and Melanie Wang
65542f9e4f
small change for for syntax keyword
2022-06-27 15:10:23 -04:00
Jake Olney and Melanie Wang
d497bfffe9
update for and tablerow
2022-06-27 15:10:22 -04:00
Jake Olney and Melanie Wang
ebafb0a3fe
changes from example feedback
2022-06-27 15:10:22 -04:00
Jake Olney and Melanie Wang
4ec9db3f99
iain feedback
2022-06-27 15:10:22 -04:00
Jake Olney and Melanie Wang
95eb5d6036
add inline_comment
2022-06-27 15:10:22 -04:00
Jake Olney and Melanie Wang
7ba40d48c0
fix lint error
2022-06-27 15:10:22 -04:00
Jake Olney and Melanie Wang
9020dbcd41
shaina feedback
2022-06-27 15:10:22 -04:00
Jake Olney and Melanie Wang
73f7467258
fix lint errors
2022-06-27 15:10:21 -04:00
Jake Olney and Melanie Wang
f3aa5fbd7c
add yard tags
2022-06-27 15:10:21 -04:00
Dylan Thacker-Smith and GitHub
eb70bb9b87
Refactor Liquid::Variable to respect disabling liquid-c nodes ( #1584 )
...
parse_context.parse_expression is overriden in liquid-c and will avoid
parsing to a Liquid::C::Expression when parsing with
`disable_liquid_c_nodes: true`
2022-06-21 15:19:56 -04:00
Dylan Thacker-Smith
f77c766262
Rename Liquid::Registers @registers to @changes
...
since it doesn't represent all the registers
2022-05-04 17:25:53 -04:00
Dylan Thacker-Smith
7bc14ae2be
Remove unused class Liquid::Register to avoid confusion
2022-05-04 17:25:52 -04:00
Dylan Thacker-Smith
41c19929ad
Rename and alias Liquid::StaticRegisters to Liquid::Registers
2022-05-04 17:25:52 -04:00
Dylan Thacker-Smith
54414dfd83
Add changelog entry, making the next release a feature release
2022-04-28 09:43:08 -04:00
Charles-P. Clermont and Dylan Thacker-Smith
1f0a0ad55c
Add # inline comment tag.
...
This commit adds a new tag named `#` that behaves like a comment.
Therefore it behaves as you'd expect any tag would work. The difference
with the comment tag is that the comment is in the tag markup and that
there is no block delimiter.
What it looks like in practice:
```liquid
{%- # this is an inline comment -%}
{% # this too is an inline comment %}
{% liquid
# required args:
assign product = product
# optional args:
assign should_show_border = should_show_border | default: true
assign should_show_cursor = should_show_cursor | default: true
%}
{% liquid
# This is a very long comment that spans multiple lines.
# It looks very similar to what it would look like if you wrote
# ruby code instead of liquid. But it doesn't have all the clunk
# of having an open tag and a close tag with so many characters.
%}
```
Co-authored-by: Dylan Thacker-Smith <[email protected] >
2022-04-28 09:38:44 -04:00
Dylan Thacker-Smith and GitHub
36dce29776
Avoid evaluating the template name in the render tag ( #1568 )
2022-04-21 16:10:42 -04:00
Chris AtLee and Dylan Thacker-Smith
6c2c621712
Ensure that partial caches are shared with subcontexts
...
Make Context use StaticRegisters by default. This makes it easier to
ensure that all subcontexts share the same static registers.
Co-authored-by: Dylan Thacker-Smith <[email protected] >
2022-04-08 10:05:58 -04:00
Marc-André Cournoyer and GitHub
f64af57b7b
Merge pull request #1540 from Watson1978/remove-redundant-regexp
...
Remove redundant regexp
2022-03-22 14:52:49 -04:00
Marc-André Cournoyer
ec6fb4d5fa
Update changelog & bump version for 5.3.0 release
2022-03-17 15:39:04 -04:00
Watson
fad58ef436
Use String#match? instead of String#=~ to reduce allocation for backreferecne
...
## Test code
```ruby
require 'benchmark/ips'
WhitespaceOrNothing = /\A\s*\z/
token = " " * 20
token =~ WhitespaceOrNothing
Benchmark.ips do |x|
x.report("=~") {
token =~ WhitespaceOrNothing
}
x.report("match?") {
token.match?(WhitespaceOrNothing)
}
x.compare!
end
```
## Result
```
Warming up --------------------------------------
=~ 271.356k i/100ms
match? 579.655k i/100ms
Calculating -------------------------------------
=~ 2.717M (± 0.4%) i/s - 13.839M in 5.092947s
match? 5.695M (± 1.6%) i/s - 28.983M in 5.090640s
Comparison:
match?: 5694747.3 i/s
=~: 2717370.9 i/s - 2.10x (± 0.00) slower
```
2022-03-16 12:44:27 +09:00
Watson
22568080b1
Revert "Use strip & empty? to detect Whitespaces"
...
This reverts commit dd7ed00ec4 .
2022-03-16 12:33:45 +09:00
Watson
dd7ed00ec4
Use strip & empty? to detect Whitespaces
...
## Test code
```ruby
require 'benchmark/ips'
WhitespaceOrNothing = /\A\s*\z/
token = " " * 20
Benchmark.ips do |x|
x.report("WhitespaceOrNothing") {
token =~ WhitespaceOrNothing
}
x.report("strip & empty?") {
token.strip.empty?
}
x.compare!
end
```
## Result
```
Warming up --------------------------------------
WhitespaceOrNothing 266.391k i/100ms
strip & empty? 1.044M i/100ms
Calculating -------------------------------------
WhitespaceOrNothing 2.705M (± 0.4%) i/s - 13.586M in 5.023453s
strip & empty? 10.400M (± 1.1%) i/s - 52.182M in 5.017990s
Comparison:
strip & empty?: 10400286.2 i/s
WhitespaceOrNothing: 2704552.3 i/s - 3.85x (± 0.00) slower
```
2022-03-12 19:24:56 +09: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
Thierry Joyal
4af38bc549
[StandardFilter] Fix missing @context on iterations
2022-03-07 09:17:07 -05:00
Peter Zhu and GitHub
3f7edf00b9
Merge pull request #1531 from Shopify/pz-array-fetch-warning
...
Fix warning about block and default value
2022-03-02 16:25:23 -05:00
Thierry Joyal
1d2bee1f60
Condition#evaluate to receive mandatory context argument
2022-03-02 14:35:31 -05:00
Peter Zhu
01e6eec97a
Fix warning about block and default value
...
Ruby's Array#fetch accepts either a default value or a block, but not
both. If both are passed in, then it uses the block and outputs this
warning:
```
lib/liquid/static_registers.rb:34: warning: block supersedes default value argument
```
2022-03-02 14:33:12 -05:00
Jean Boussier
a7eb33fa39
Release 5.2.0
2022-03-01 16:18:49 +01:00
Jean Boussier
c588337aac
Eagerly cache global filters
...
Including a module can cause Ruby's global constant cache to be busted
if the included module contain constants. So that's something you don't
want to happen at "runtime", otherwise it will severely degrade performance
and if you are using YJIT or MJIT most of the compiled code will be invalidated.
To limit the impact of this, we can pre-include the global filters,
as they're generally registered during boot, that limits the problem
to non-global filters.
2022-03-01 13:40:40 +01:00
0d83e64cfe
Add replace_last and remove_last filters ( #1422 )
...
Co-authored-by: ADTC <[email protected] >
Co-authored-by: Dylan Thacker-Smith <[email protected] >
2022-02-24 14:02:15 -05:00
Dylan Thacker-Smith and GitHub
0d5e01ae98
Fix some internal errors in filters from invalid input. ( #1476 )
...
These fixes came from improving the corresponding test, so these might not
actually be causing problems in practice.
2022-02-24 09:17:37 -05:00
Charles-Philippe Clermont and GitHub
15eaa49e48
Merge pull request #1518 from Shopify/fix/kwarg-key-name-liquid-c-inconsistency
...
Fix kwarg parsing inconsistency with Liquid::C
2022-02-14 13:22:12 -05:00
Charles-P. Clermont
1310c4978d
Fix kwarg parsing inconsistency with Liquid::C
...
Liquid::C parses liquid filter arguments with dashes in them, Liquid does not.
For tags that accept kwargs and dumps them on the HTML tag, this is an important feature.
e.g. {{ ... | image_tag: loading: 'lazy', data-something: 'value!' }}
Without this change, Liquid would incorrectly parse the
`data-something` kwarg as a single argument and would skip over the
invalid characters.
See https://github.com/Shopify/theme-check/issues/539 for more context
2022-02-11 15:10:07 -05:00
Watson
ebdfdb80e5
Detect quoted string using String#{start_with?, end_with?} to reduce Regexp#=== calling
2021-09-26 04:30:49 +09:00
Watson
95e9fa5010
Use String#=~ and Regexp.last_match instead to retrieve the markup content
...
If the first value is only used obtained with String#scan,
it will increase the performance if replace with `String#=~` and `Regexp.last_match`.
### Environment
- MacBook Air (M1, 2020)
- macOS 12.0 beta 7
- Apple M1
- Ruby 3.0.2
### Test code
```ruby
require 'benchmark/ips'
WhitespaceControl = '-'
VariableStart = /\{\{/
VariableEnd = /\}\}/
ContentOfVariable = /\A#{VariableStart}#{WhitespaceControl}?(.*?)#{WhitespaceControl}?#{VariableEnd}\z/om
token = "{{item.product.featured_image | product_img_url: 'thumb' }}"
Benchmark.ips do |x|
x.report("String#scan") { token.scan(ContentOfVariable) {|content| break } }
x.report("String#match") { m = token.match(ContentOfVariable); m[1] }
x.report("String#=~") { token =~ ContentOfVariable; Regexp.last_match(1) }
x.compare!
end
```
### Result
```
Warming up --------------------------------------
String#scan 135.724k i/100ms
String#match 117.397k i/100ms
String#=~ 151.637k i/100ms
Calculating -------------------------------------
String#scan 1.351M (± 0.8%) i/s - 6.786M in 5.021955s
String#match 1.169M (± 1.3%) i/s - 5.870M in 5.020429s
String#=~ 1.520M (± 0.9%) i/s - 7.733M in 5.087427s
Comparison:
String#=~: 1520250.9 i/s
String#scan: 1351399.0 i/s - 1.12x (± 0.00) slower
String#match: 1169384.1 i/s - 1.30x (± 0.00) slower
```
2021-09-26 04:12:53 +09:00
Marc-André Cournoyer and GitHub
10e2aa8d5b
Merge pull request #1471 from Shopify/bump-5.1.0
...
Prep for 5.1.0 release
2021-09-15 15:15:13 -04:00
Marc-André Cournoyer
b01de9d325
Prep for 5.1.0 release
2021-09-09 14:28:45 -04:00
Zac Clay and GitHub
a5369c26a8
Add missing quote in comment ( #1468 )
2021-09-09 14:23:11 -04:00
Charles-P. Clermont
e86fe27259
Fix lint
2021-09-09 11:22:39 -04:00
Charles-P. Clermont
c8906d05b9
Add ParseTreeVisitor to RangeLookup
2021-09-09 11:22:39 -04:00
Michael Go and GitHub
50d1a2ffc9
Merge pull request #1458 from Shopify/use-to-liquid-value-with-conditions
...
use Utils.to_liquid_value on conditionals
2021-06-15 12:18:14 -03:00
Michael Go
f686c5dec7
use Utils.to_liquid_value on conditionals
2021-06-14 18:19:37 -03:00
Michael Go and GitHub
aa8ce87b96
Merge pull request #1454 from Shopify/default-filter-with-to-liquid-value
...
utilize input's to_liquid_value on default filter
2021-06-14 15:43:56 -03:00
Michael Go
edd4d70aee
fix unless to use to_liquid_value helper with multiple conditions
2021-06-10 13:28:17 -03:00
Michael Go
ac66dbbafe
utilize input's to_liquid_value on default filter
2021-06-08 15:20:53 -03:00
Daniel Insley and GitHub
017c1b5e83
Base64 Decode & Encode Filters ( #1450 )
2021-06-03 13:23:11 -04:00
Michael Go
e361a4d53c
introduce to_liquid_value on variable look and conditional statements
2021-05-26 17:27:18 -03:00
Dylan Thacker-Smith and GitHub
cfe1637bdd
Translate RangeError to Liquid::Error for truncatewords with large int ( #1431 )
2021-04-20 11:48:22 -04:00
Dylan Thacker-Smith
eab13a07d9
Add changelog entry for a recent fix
2021-03-29 13:43:01 -07:00
Dylan Thacker-Smith and GitHub
ca96ca0fef
Fix support for using a String subclass for the liquid source ( #1421 )
2021-03-29 16:22:05 -04:00