liquid 5.8.1 → 5.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9df4f1181afa3219bb511d91aa42bf71a66f9754e21c1d757b08e0755cc52644
4
- data.tar.gz: d0889eb7e14469f37995032e321f59beb7d92c544676b3a37e29de4128e560f7
3
+ metadata.gz: cb3ff5ebbdba41e779d9f36565fe3331aa83abe4ff382ff13a6b4df0f64168e4
4
+ data.tar.gz: 2cf06ebce1bb089de5c57af9e3e65020f2b4fbc1b34c567867279f74983e2482
5
5
  SHA512:
6
- metadata.gz: 6003582f214cfab241a8160f549203c1b1e7719dad67e5af145f9c0d424a46c6fde121801a87bf5094a84c955114e96d3ba2874ceb5f927dbd83372bf1ba2130
7
- data.tar.gz: 4358f9616737c9aa3b6e61d1bb723e38e8d5446c157654ea894c09efb375e9c2e01eb4dfbec9c243207bf2750c87702f21698d31f53bed4848e1a5c7ea155677
6
+ metadata.gz: e970f6c89af0a8b593d714ddc8c9328893a7703d39cc9e8937ccc838538fee13de85c62390bf610af7e85bb30d91b328fba2f9e388a9c67b00ddaaf374939973
7
+ data.tar.gz: 4f6f8a3b237ee1146debb6994278d9a39bc0da045b7e2eaeabea8f5dac2a4a71d434c3d2b69f55f6dc8e8619801bfa7795a97dae8cc9e073ee474007a6f58067
@@ -3,7 +3,6 @@
3
3
  require 'cgi'
4
4
  require 'base64'
5
5
  require 'bigdecimal'
6
-
7
6
  module Liquid
8
7
  module StandardFilters
9
8
  MAX_I32 = (1 << 31) - 1
@@ -387,6 +386,7 @@ module Liquid
387
386
  end
388
387
  elsif ary.all? { |el| el.respond_to?(:[]) }
389
388
  begin
389
+ property = Utils.to_s(property)
390
390
  ary.sort { |a, b| nil_safe_compare(a[property], b[property]) }
391
391
  rescue TypeError
392
392
  raise_property_error(property)
@@ -416,6 +416,7 @@ module Liquid
416
416
  end
417
417
  elsif ary.all? { |el| el.respond_to?(:[]) }
418
418
  begin
419
+ property = Utils.to_s(property)
419
420
  ary.sort { |a, b| nil_safe_casecmp(a[property], b[property]) }
420
421
  rescue TypeError
421
422
  raise_property_error(property)
@@ -503,6 +504,7 @@ module Liquid
503
504
  elsif ary.empty? # The next two cases assume a non-empty array.
504
505
  []
505
506
  else
507
+ property = Utils.to_s(property)
506
508
  ary.uniq do |item|
507
509
  item[property]
508
510
  rescue TypeError
@@ -534,6 +536,11 @@ module Liquid
534
536
  # @liquid_syntax array | map: string
535
537
  # @liquid_return [array[untyped]]
536
538
  def map(input, property)
539
+ property = Utils.to_s(property)
540
+
541
+ # Return the input array if property is empty (no-op)
542
+ return InputIterator.new(input, context).to_a if property.empty?
543
+
537
544
  InputIterator.new(input, context).map do |e|
538
545
  e = e.call if e.is_a?(Proc)
539
546
 
@@ -563,6 +570,7 @@ module Liquid
563
570
  elsif ary.empty? # The next two cases assume a non-empty array.
564
571
  []
565
572
  else
573
+ property = Liquid::Utils.to_s(property)
566
574
  ary.reject do |item|
567
575
  item[property].nil?
568
576
  rescue TypeError
@@ -712,7 +720,16 @@ module Liquid
712
720
  input.gsub(/\r?\n/, "<br />\n")
713
721
  end
714
722
 
715
- # Reformat a date using Ruby's core Time#strftime( string ) -> string
723
+ # @liquid_public_docs
724
+ # @liquid_type filter
725
+ # @liquid_category date
726
+ # @liquid_summary
727
+ # Formats a date according to a specified format string.
728
+ # @liquid_description
729
+ # This filter formats a date using various format specifiers. If the format string is empty,
730
+ # the original input is returned. If the input cannot be converted to a date, the original input is returned.
731
+ #
732
+ # The following format specifiers can be used:
716
733
  #
717
734
  # %a - The abbreviated weekday name (``Sun'')
718
735
  # %A - The full weekday name (``Sunday'')
@@ -741,8 +758,8 @@ module Liquid
741
758
  # %Y - Year with century
742
759
  # %Z - Time zone name
743
760
  # %% - Literal ``%'' character
744
- #
745
- # See also: http://www.ruby-doc.org/core/Time.html#method-i-strftime
761
+ # @liquid_syntax date | date: string
762
+ # @liquid_return [string]
746
763
  def date(input, format)
747
764
  str_format = Utils.to_s(format)
748
765
  return input if str_format.empty?
@@ -943,6 +960,8 @@ module Liquid
943
960
  # @liquid_syntax array | sum
944
961
  # @liquid_return [number]
945
962
  def sum(input, property = nil)
963
+ property = property.nil? ? nil : Utils.to_s(property)
964
+
946
965
  ary = InputIterator.new(input, context)
947
966
  return 0 if ary.empty?
948
967
 
@@ -971,9 +990,10 @@ module Liquid
971
990
 
972
991
  def filter_array(input, property, target_value, default_value = [], &block)
973
992
  ary = InputIterator.new(input, context)
974
-
975
993
  return default_value if ary.empty?
976
994
 
995
+ property = Utils.to_s(property)
996
+
977
997
  block.call(ary) do |item|
978
998
  if target_value.nil?
979
999
  item[property]
@@ -10,7 +10,7 @@ module Liquid
10
10
  # @liquid_description
11
11
  # Variables that are declared with `decrement` are unique to the [layout](/themes/architecture/layouts), [template](/themes/architecture/templates),
12
12
  # or [section](/themes/architecture/sections) file that they're created in. However, the variable is shared across
13
- # [snippets](/themes/architecture#snippets) included in the file.
13
+ # [snippets](/themes/architecture/snippets) included in the file.
14
14
  #
15
15
  # Similarly, variables that are created with `decrement` are independent from those created with [`assign`](/docs/api/liquid/tags/assign)
16
16
  # and [`capture`](/docs/api/liquid/tags/capture). However, `decrement` and [`increment`](/docs/api/liquid/tags/increment) share
@@ -13,12 +13,16 @@ module Liquid
13
13
  # Liquid code inside will be parsed but not executed. This facilitates
14
14
  # tooling support for features like code completion, linting, and inline
15
15
  # documentation.
16
+ #
17
+ # For detailed documentation syntax and examples, see the
18
+ # [`LiquidDoc` reference](/docs/storefronts/themes/tools/liquid-doc).
19
+ #
16
20
  # @liquid_syntax
17
21
  # {% doc %}
18
22
  # Renders a message.
19
23
  #
20
- # @param {string} foo - A foo value.
21
- # @param {string} [bar] - An optional bar value.
24
+ # @param {string} foo - A string value.
25
+ # @param {string} [bar] - An optional string value.
22
26
  #
23
27
  # @example
24
28
  # {% render 'message', foo: 'Hello', bar: 'World' %}
@@ -6,7 +6,7 @@ module Liquid
6
6
  # @liquid_category theme
7
7
  # @liquid_name include
8
8
  # @liquid_summary
9
- # Renders a [snippet](/themes/architecture#snippets).
9
+ # Renders a [snippet](/themes/architecture/snippets).
10
10
  # @liquid_description
11
11
  # Inside the snippet, you can access and alter variables that are [created](/docs/api/liquid/tags/variable-tags) outside of the
12
12
  # snippet.
@@ -10,7 +10,7 @@ module Liquid
10
10
  # @liquid_description
11
11
  # Variables that are declared with `increment` are unique to the [layout](/themes/architecture/layouts), [template](/themes/architecture/templates),
12
12
  # or [section](/themes/architecture/sections) file that they're created in. However, the variable is shared across
13
- # [snippets](/themes/architecture#snippets) included in the file.
13
+ # [snippets](/themes/architecture/snippets) included in the file.
14
14
  #
15
15
  # Similarly, variables that are created with `increment` are independent from those created with [`assign`](/docs/api/liquid/tags/assign)
16
16
  # and [`capture`](/docs/api/liquid/tags/capture). However, `increment` and [`decrement`](/docs/api/liquid/tags/decrement) share
@@ -6,7 +6,7 @@ module Liquid
6
6
  # @liquid_category theme
7
7
  # @liquid_name render
8
8
  # @liquid_summary
9
- # Renders a [snippet](/themes/architecture#snippets) or [app block](/themes/architecture/sections/section-schema#render-app-blocks).
9
+ # Renders a [snippet](/themes/architecture/snippets) or [app block](/themes/architecture/sections/section-schema#render-app-blocks).
10
10
  # @liquid_description
11
11
  # Inside snippets and app blocks, you can't directly access variables that are [created](/docs/api/liquid/tags/variable-tags) outside
12
12
  # of the snippet or app block. However, you can [specify variables as parameters](/docs/api/liquid/tags/render#render-passing-variables-to-a-snippet)
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Liquid
5
- VERSION = "5.8.1"
5
+ VERSION = "5.8.3"
6
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquid
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.8.1
4
+ version: 5.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Lütke
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-26 00:00:00.000000000 Z
10
+ date: 2025-04-04 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: strscan
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: 1.3.7
161
161
  requirements: []
162
- rubygems_version: 3.6.3
162
+ rubygems_version: 3.6.6
163
163
  specification_version: 4
164
164
  summary: A secure, non-evaling end user template engine with aesthetic markup.
165
165
  test_files: []