liquid 3.0.6 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +5 -5
  2. data/History.md +243 -58
  3. data/README.md +43 -4
  4. data/lib/liquid/block.rb +57 -123
  5. data/lib/liquid/block_body.rb +217 -85
  6. data/lib/liquid/condition.rb +92 -45
  7. data/lib/liquid/context.rb +154 -89
  8. data/lib/liquid/document.rb +57 -9
  9. data/lib/liquid/drop.rb +20 -17
  10. data/lib/liquid/errors.rb +27 -29
  11. data/lib/liquid/expression.rb +32 -20
  12. data/lib/liquid/extensions.rb +21 -7
  13. data/lib/liquid/file_system.rb +17 -15
  14. data/lib/liquid/forloop_drop.rb +92 -0
  15. data/lib/liquid/i18n.rb +10 -8
  16. data/lib/liquid/interrupts.rb +4 -3
  17. data/lib/liquid/lexer.rb +37 -26
  18. data/lib/liquid/locales/en.yml +13 -6
  19. data/lib/liquid/parse_context.rb +54 -0
  20. data/lib/liquid/parse_tree_visitor.rb +42 -0
  21. data/lib/liquid/parser.rb +30 -18
  22. data/lib/liquid/parser_switching.rb +20 -6
  23. data/lib/liquid/partial_cache.rb +24 -0
  24. data/lib/liquid/profiler/hooks.rb +26 -14
  25. data/lib/liquid/profiler.rb +72 -92
  26. data/lib/liquid/range_lookup.rb +28 -3
  27. data/lib/liquid/registers.rb +51 -0
  28. data/lib/liquid/resource_limits.rb +62 -0
  29. data/lib/liquid/standardfilters.rb +715 -132
  30. data/lib/liquid/strainer_factory.rb +41 -0
  31. data/lib/liquid/strainer_template.rb +62 -0
  32. data/lib/liquid/tablerowloop_drop.rb +121 -0
  33. data/lib/liquid/tag/disableable.rb +22 -0
  34. data/lib/liquid/tag/disabler.rb +21 -0
  35. data/lib/liquid/tag.rb +35 -12
  36. data/lib/liquid/tags/assign.rb +57 -18
  37. data/lib/liquid/tags/break.rb +15 -5
  38. data/lib/liquid/tags/capture.rb +24 -18
  39. data/lib/liquid/tags/case.rb +79 -30
  40. data/lib/liquid/tags/comment.rb +19 -4
  41. data/lib/liquid/tags/continue.rb +16 -12
  42. data/lib/liquid/tags/cycle.rb +47 -27
  43. data/lib/liquid/tags/decrement.rb +23 -24
  44. data/lib/liquid/tags/echo.rb +41 -0
  45. data/lib/liquid/tags/for.rb +155 -124
  46. data/lib/liquid/tags/if.rb +97 -63
  47. data/lib/liquid/tags/ifchanged.rb +11 -12
  48. data/lib/liquid/tags/include.rb +82 -73
  49. data/lib/liquid/tags/increment.rb +23 -17
  50. data/lib/liquid/tags/inline_comment.rb +43 -0
  51. data/lib/liquid/tags/raw.rb +50 -8
  52. data/lib/liquid/tags/render.rb +109 -0
  53. data/lib/liquid/tags/table_row.rb +57 -41
  54. data/lib/liquid/tags/unless.rb +38 -20
  55. data/lib/liquid/template.rb +71 -103
  56. data/lib/liquid/template_factory.rb +9 -0
  57. data/lib/liquid/tokenizer.rb +39 -0
  58. data/lib/liquid/usage.rb +8 -0
  59. data/lib/liquid/utils.rb +63 -9
  60. data/lib/liquid/variable.rb +74 -56
  61. data/lib/liquid/variable_lookup.rb +31 -15
  62. data/lib/liquid/version.rb +3 -1
  63. data/lib/liquid.rb +27 -12
  64. metadata +30 -106
  65. data/lib/liquid/module_ex.rb +0 -62
  66. data/lib/liquid/strainer.rb +0 -59
  67. data/lib/liquid/token.rb +0 -18
  68. data/test/fixtures/en_locale.yml +0 -9
  69. data/test/integration/assign_test.rb +0 -48
  70. data/test/integration/blank_test.rb +0 -106
  71. data/test/integration/capture_test.rb +0 -50
  72. data/test/integration/context_test.rb +0 -32
  73. data/test/integration/drop_test.rb +0 -271
  74. data/test/integration/error_handling_test.rb +0 -207
  75. data/test/integration/filter_test.rb +0 -138
  76. data/test/integration/hash_ordering_test.rb +0 -23
  77. data/test/integration/output_test.rb +0 -124
  78. data/test/integration/parsing_quirks_test.rb +0 -116
  79. data/test/integration/render_profiling_test.rb +0 -154
  80. data/test/integration/security_test.rb +0 -64
  81. data/test/integration/standard_filter_test.rb +0 -396
  82. data/test/integration/tags/break_tag_test.rb +0 -16
  83. data/test/integration/tags/continue_tag_test.rb +0 -16
  84. data/test/integration/tags/for_tag_test.rb +0 -375
  85. data/test/integration/tags/if_else_tag_test.rb +0 -190
  86. data/test/integration/tags/include_tag_test.rb +0 -234
  87. data/test/integration/tags/increment_tag_test.rb +0 -24
  88. data/test/integration/tags/raw_tag_test.rb +0 -25
  89. data/test/integration/tags/standard_tag_test.rb +0 -297
  90. data/test/integration/tags/statements_test.rb +0 -113
  91. data/test/integration/tags/table_row_test.rb +0 -63
  92. data/test/integration/tags/unless_else_tag_test.rb +0 -26
  93. data/test/integration/template_test.rb +0 -182
  94. data/test/integration/variable_test.rb +0 -82
  95. data/test/test_helper.rb +0 -89
  96. data/test/unit/block_unit_test.rb +0 -55
  97. data/test/unit/condition_unit_test.rb +0 -149
  98. data/test/unit/context_unit_test.rb +0 -492
  99. data/test/unit/file_system_unit_test.rb +0 -35
  100. data/test/unit/i18n_unit_test.rb +0 -37
  101. data/test/unit/lexer_unit_test.rb +0 -48
  102. data/test/unit/module_ex_unit_test.rb +0 -87
  103. data/test/unit/parser_unit_test.rb +0 -82
  104. data/test/unit/regexp_unit_test.rb +0 -44
  105. data/test/unit/strainer_unit_test.rb +0 -69
  106. data/test/unit/tag_unit_test.rb +0 -16
  107. data/test/unit/tags/case_tag_unit_test.rb +0 -10
  108. data/test/unit/tags/for_tag_unit_test.rb +0 -13
  109. data/test/unit/tags/if_tag_unit_test.rb +0 -8
  110. data/test/unit/template_unit_test.rb +0 -69
  111. data/test/unit/tokenizer_unit_test.rb +0 -38
  112. data/test/unit/variable_unit_test.rb +0 -145
  113. /data/{MIT-LICENSE → LICENSE} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d261e9933d148ea6cd126089810b2ab38c510d84
4
- data.tar.gz: bab6c47dafec91fb743720a77430e4c662108482
2
+ SHA256:
3
+ metadata.gz: c8408df245a1cc22ee1154fe5387e3e41eb3c740f7277e7d3736c1863d387e47
4
+ data.tar.gz: 64549a58828fd7e9e0eb7310cb4371e75e64a7c3249fe9ebd021039e3334bba1
5
5
  SHA512:
6
- metadata.gz: 2d6e8d2d67a425d95afe16df6e99322fde8792ad51019a94c39d0169c98def33aa862845ffcaef1ec660d0f524985692c23335865d82d5ea6703caa10427c9d8
7
- data.tar.gz: 0b66d763cd81d42c3cf38adad9693df294eb356f880a920c109f504cf827c48729df1bdb9c22104386776dd9140101dfa1db5f9b0d9b0691620f81937cdcc01b
6
+ metadata.gz: 29aaff16e3bc464712cdcac3aa205df943132198ef9568d46f4a123d327849f7ead7bd669a095eae0425581eb59ea08874ac38664bf9d8df00b0aa99917c7768
7
+ data.tar.gz: 9f6070c39733b7f4064f70676b1f886fc61070f3ba8921360b9c5fcdb09c217b3e58c3d59d8293b24b6c18e55899ed17552a2f867ea8eb95e7dee9a7deb29ae5
data/History.md CHANGED
@@ -1,4 +1,189 @@
1
- # Liquid Version History
1
+ # Liquid Change Log
2
+
3
+ ## 5.4.0 2022-07-29
4
+
5
+ ### Breaking Changes
6
+ * Drop support for end-of-life Ruby versions (2.5 and 2.6) (#1578) [Andy Waite]
7
+
8
+ ### Features
9
+ * Allow `#` to be used as an inline comment tag (#1498) [CP Clermont]
10
+
11
+ ### Fixes
12
+ * `PartialCache` now shares snippet cache with subcontexts by default (#1553) [Chris AtLee]
13
+ * Hash registers no longer leak into subcontexts as static registers (#1564) [Chris AtLee]
14
+ * Fix `ParseTreeVisitor` for `with` variable expressions in `Render` tag (#1596) [CP Clermont]
15
+
16
+ ### Changed
17
+ * Liquid::Context#registers now always returns a Liquid::Registers object, though supports the most used Hash functions for compatibility (#1553)
18
+
19
+ ## 5.3.0 2022-03-22
20
+
21
+ ### Fixes
22
+ * StandardFilter: Fix missing @context on iterations (#1525) [Thierry Joyal]
23
+ * Fix warning about block and default value in `static_registers.rb` (#1531) [Peter Zhu]
24
+
25
+ ### Deprecation
26
+ * Condition#evaluate to require mandatory context argument in Liquid 6.0.0 (#1527) [Thierry Joyal]
27
+
28
+ ## 5.2.0 2022-03-01
29
+
30
+ ### Features
31
+ * Add `remove_last`, and `replace_last` filters (#1422) [Anders Hagbard]
32
+ * Eagerly cache global filters (#1524) [Jean Boussier]
33
+
34
+ ### Fixes
35
+ * Fix some internal errors in filters from invalid input (#1476) [Dylan Thacker-Smith]
36
+ * Allow dash in filter kwarg name for consistency with Liquid::C (#1518) [CP Clermont]
37
+
38
+ ## 5.1.0 / 2021-09-09
39
+
40
+ ### Features
41
+ * Add `base64_encode`, `base64_decode`, `base64_url_safe_encode`, and `base64_url_safe_decode` filters (#1450) [Daniel Insley]
42
+ * Introduce `to_liquid_value` in `Liquid::Drop` (#1441) [Michael Go]
43
+
44
+ ### Fixes
45
+ * Fix support for using a String subclass for the liquid source (#1421) [Dylan Thacker-Smith]
46
+ * Add `ParseTreeVisitor` to `RangeLookup` (#1470) [CP Clermont]
47
+ * Translate `RangeError` to `Liquid::Error` for `truncatewords` with large int (#1431) [Dylan Thacker-Smith]
48
+
49
+ ## 5.0.1 / 2021-03-24
50
+
51
+ ### Fixes
52
+ * Add ParseTreeVisitor to Echo tag (#1414) [CP Clermont]
53
+ * Test with ruby 3.0 as the latest ruby version (#1398) [Dylan Thacker-Smith]
54
+ * Handle carriage return in newlines_to_br (#1391) [Unending]
55
+
56
+ ### Performance Improvements
57
+ * Use split limit in truncatewords (#1361) [Dylan Thacker-Smith]
58
+
59
+ ## 5.0.0 / 2021-01-06
60
+
61
+ ### Features
62
+ * Add new `{% render %}` tag (#1122) [Samuel Doiron]
63
+ * Add support for `as` in `{% render %}` and `{% include %}` (#1181) [Mike Angell]
64
+ * Add `{% liquid %}` and `{% echo %}` tags (#1086) [Justin Li]
65
+ * Add [usage tracking](README.md#usage-tracking) [Mike Angell]
66
+ * Add `Tag.disable_tags` for disabling tags that prepend `Tag::Disableable` at render time (#1162, #1274, #1275) [Mike Angell]
67
+ * Support using a profiler for multiple renders (#1365, #1366) [Dylan Thacker-Smith]
68
+
69
+ ### Fixes
70
+ * Fix catastrophic backtracking in `RANGES_REGEX` regular expression (#1357) [Dylan Thacker-Smith]
71
+ * Make sure the for tag's limit and offset are integers (#1094) [David Cornu]
72
+ * Invokable methods for enumerable reject include (#1151) [Thierry Joyal]
73
+ * Allow `default` filter to handle `false` as value (#1144) [Mike Angell]
74
+ * Fix render length resource limit so it doesn't multiply nested output (#1285) [Dylan Thacker-Smith]
75
+ * Fix duplication of text in raw tags (#1304) [Peter Zhu]
76
+ * Fix strict parsing of find variable with a name expression (#1317) [Dylan Thacker-Smith]
77
+ * Use monotonic time to measure durations in Liquid::Profiler (#1362) [Dylan Thacker-Smith]
78
+
79
+ ### Breaking Changes
80
+ * Require Ruby >= 2.5 (#1131, #1310) [Mike Angell, Dylan Thacker-Smith]
81
+ * Remove support for taint checking (#1268) [Dylan Thacker-Smith]
82
+ * Split Strainer class into StrainerFactory and StrainerTemplate (#1208) [Thierry Joyal]
83
+ * Remove handling of a nil context in the Strainer class (#1218) [Thierry Joyal]
84
+ * Handle `BlockBody#blank?` at parse time (#1287) [Dylan Thacker-Smith]
85
+ * Pass the tag markup and tokenizer to `Document#unknown_tag` (#1290) [Dylan Thacker-Smith]
86
+ * And several internal changes
87
+
88
+ ### Performance Improvements
89
+ * Reduce allocations (#1073, #1091, #1115, #1099, #1117, #1141, #1322, #1341) [Richard Monette, Florian Weingarten, Ashwin Maroli]
90
+ * Improve resources limits performance (#1093, #1323) [Florian Weingarten, Dylan Thacker-Smith]
91
+
92
+ ## 4.0.3 / 2019-03-12
93
+
94
+ ### Fixed
95
+ * Fix break and continue tags inside included templates in loops (#1072) [Justin Li]
96
+
97
+ ## 4.0.2 / 2019-03-08
98
+
99
+ ### Changed
100
+ * Add `where` filter (#1026) [Samuel Doiron]
101
+ * Add `ParseTreeVisitor` to iterate the Liquid AST (#1025) [Stephen Paul Weber]
102
+ * Improve `strip_html` performance (#1032) [printercu]
103
+
104
+ ### Fixed
105
+ * Add error checking for invalid combinations of inputs to sort, sort_natural, where, uniq, map, compact filters (#1059) [Garland Zhang]
106
+ * Validate the character encoding in url_decode (#1070) [Clayton Smith]
107
+
108
+ ## 4.0.1 / 2018-10-09
109
+
110
+ ### Changed
111
+ * Add benchmark group in Gemfile (#855) [Jerry Liu]
112
+ * Allow benchmarks to benchmark render by itself (#851) [Jerry Liu]
113
+ * Avoid calling `line_number` on String node when rescuing a render error. (#860) [Dylan Thacker-Smith]
114
+ * Avoid duck typing to detect whether to call render on a node. [Dylan Thacker-Smith]
115
+ * Clarify spelling of `reversed` on `for` block tag (#843) [Mark Crossfield]
116
+ * Replace recursion with loop to avoid potential stack overflow from malicious input (#891, #892) [Dylan Thacker-Smith]
117
+ * Limit block tag nesting to 100 (#894) [Dylan Thacker-Smith]
118
+ * Replace `assert_equal nil` with `assert_nil` (#895) [Dylan Thacker-Smith]
119
+ * Remove Spy Gem (#896) [Dylan Thacker-Smith]
120
+ * Add `collection_name` and `variable_name` reader to `For` block (#909)
121
+ * Symbols render as strings (#920) [Justin Li]
122
+ * Remove default value from Hash objects (#932) [Maxime Bedard]
123
+ * Remove one level of nesting (#944) [Dylan Thacker-Smith]
124
+ * Update Rubocop version (#952) [Justin Li]
125
+ * Add `at_least` and `at_most` filters (#954, #958) [Nithin Bekal]
126
+ * Add a regression test for a liquid-c trim mode bug (#972) [Dylan Thacker-Smith]
127
+ * Use https rather than git protocol to fetch liquid-c [Dylan Thacker-Smith]
128
+ * Add tests against Ruby 2.4 (#963) and 2.5 (#981)
129
+ * Replace RegExp literals with constants (#988) [Ashwin Maroli]
130
+ * Replace unnecessary `#each_with_index` with `#each` (#992) [Ashwin Maroli]
131
+ * Improve the unexpected end delimiter message for block tags. (#1003) [Dylan Thacker-Smith]
132
+ * Refactor and optimize rendering (#1005) [Christopher Aue]
133
+ * Add installation instruction (#1006) [Ben Gift]
134
+ * Remove Circle CI (#1010)
135
+ * Rename deprecated `BigDecimal.new` to `BigDecimal` (#1024) [Koichi ITO]
136
+ * Rename deprecated Rubocop name (#1027) [Justin Li]
137
+
138
+ ### Fixed
139
+ * Handle `join` filter on non String joiners (#857) [Richard Monette]
140
+ * Fix duplicate inclusion condition logic error of `Liquid::Strainer.add_filter` method (#861)
141
+ * Fix `escape`, `url_encode`, `url_decode` not handling non-string values (#898) [Thierry Joyal]
142
+ * Fix raise when variable is defined but nil when using `strict_variables` [Pascal Betz]
143
+ * Fix `sort` and `sort_natural` to handle arrays with nils (#930) [Eric Chan]
144
+
145
+ ## 4.0.0 / 2016-12-14 / branch "4-0-stable"
146
+
147
+ ### Changed
148
+ * Render an opaque internal error by default for non-Liquid::Error (#835) [Dylan Thacker-Smith]
149
+ * Ruby 2.0 support dropped (#832) [Dylan Thacker-Smith]
150
+ * Add to_number Drop method to allow custom drops to work with number filters (#731)
151
+ * Add strict_variables and strict_filters options to detect undefined references (#691)
152
+ * Improve loop performance (#681) [Florian Weingarten]
153
+ * Rename Drop method `before_method` to `liquid_method_missing` (#661) [Thierry Joyal]
154
+ * Add url_decode filter to invert url_encode (#645) [Larry Archer]
155
+ * Add global_filter to apply a filter to all output (#610) [Loren Hale]
156
+ * Add compact filter (#600) [Carson Reinke]
157
+ * Rename deprecated "has_key?" and "has_interrupt?" methods (#593) [Florian Weingarten]
158
+ * Include template name with line numbers in render errors (574) [Dylan Thacker-Smith]
159
+ * Add sort_natural filter (#554) [Martin Hanzel]
160
+ * Add forloop.parentloop as a reference to the parent loop (#520) [Justin Li]
161
+ * Block parsing moved to BlockBody class (#458) [Dylan Thacker-Smith]
162
+ * Add concat filter to concatenate arrays (#429) [Diogo Beato]
163
+ * Ruby 1.9 support dropped (#491) [Justin Li]
164
+ * Liquid::Template.file_system's read_template_file method is no longer passed the context. (#441) [James Reid-Smith]
165
+ * Remove `liquid_methods` (See https://github.com/Shopify/liquid/pull/568 for replacement)
166
+ * Liquid::Template.register_filter raises when the module overrides registered public methods as private or protected (#705) [Gaurav Chande]
167
+
168
+ ### Fixed
169
+
170
+ * Fix variable names being detected as an operator when starting with contains (#788) [Michael Angell]
171
+ * Fix include tag used with strict_variables (#828) [QuickPay]
172
+ * Fix map filter when value is a Proc (#672) [Guillaume Malette]
173
+ * Fix truncate filter when value is not a string (#672) [Guillaume Malette]
174
+ * Fix behaviour of escape filter when input is nil (#665) [Tanel Jakobsoo]
175
+ * Fix sort filter behaviour with empty array input (#652) [Marcel Cary]
176
+ * Fix test failure under certain timezones (#631) [Dylan Thacker-Smith]
177
+ * Fix bug in uniq filter (#595) [Florian Weingarten]
178
+ * Fix bug when "blank" and "empty" are used as variable names (#592) [Florian Weingarten]
179
+ * Fix condition parse order in strict mode (#569) [Justin Li]
180
+ * Fix naming of the "context variable" when dynamically including a template (#559) [Justin Li]
181
+ * Gracefully accept empty strings in the date filter (#555) [Loren Hale]
182
+ * Fix capturing into variables with a hyphen in the name (#505) [Florian Weingarten]
183
+ * Fix case sensitivity regression in date standard filter (#499) [Kelley Reynolds]
184
+ * Disallow filters with no variable in strict mode (#475) [Justin Li]
185
+ * Disallow variable names in the strict parser that are not valid in the lax parser (#463) [Justin Li]
186
+ * Fix BlockBody#warnings taking exponential time to compute (#486) [Justin Li]
2
187
 
3
188
  ## 3.0.5 / 2015-07-23 / branch "3-0-stable"
4
189
 
@@ -10,11 +195,11 @@
10
195
 
11
196
  ## 3.0.3 / 2015-05-28
12
197
 
13
- * Fix condition parse order in strict mode (#569) [Justin Li, pushrax]
198
+ * Fix condition parse order in strict mode (#569) [Justin Li]
14
199
 
15
200
  ## 3.0.2 / 2015-04-24
16
201
 
17
- * Expose VariableLookup private members (#551) [Justin Li, pushrax]
202
+ * Expose VariableLookup private members (#551) [Justin Li]
18
203
  * Documentation fixes
19
204
 
20
205
  ## 3.0.1 / 2015-01-23
@@ -23,38 +208,38 @@
23
208
 
24
209
  ## 3.0.0 / 2014-11-12
25
210
 
26
- * Removed Block#end_tag. Instead, override parse with `super` followed by your code. See #446 [Dylan Thacker-Smith, dylanahsmith]
27
- * Fixed condition with wrong data types, see #423 [Bogdan Gusiev]
28
- * Add url_encode to standard filters, see #421 [Derrick Reimer, djreimer]
29
- * Add uniq to standard filters [Florian Weingarten, fw42]
30
- * Add exception_handler feature, see #397 and #254 [Bogdan Gusiev, bogdan and Florian Weingarten, fw42]
31
- * Optimize variable parsing to avoid repeated regex evaluation during template rendering #383 [Jason Hiltz-Laforge, jasonhl]
32
- * Optimize checking for block interrupts to reduce object allocation #380 [Jason Hiltz-Laforge, jasonhl]
33
- * Properly set context rethrow_errors on render! #349 [Thierry Joyal, tjoyal]
34
- * Fix broken rendering of variables which are equal to false, see #345 [Florian Weingarten, fw42]
35
- * Remove ActionView template handler [Dylan Thacker-Smith, dylanahsmith]
36
- * Freeze lots of string literals for new Ruby 2.1 optimization, see #297 [Florian Weingarten, fw42]
37
- * Allow newlines in tags and variables, see #324 [Dylan Thacker-Smith, dylanahsmith]
38
- * Tag#parse is called after initialize, which now takes options instead of tokens as the 3rd argument. See #321 [Dylan Thacker-Smith, dylanahsmith]
39
- * Raise `Liquid::ArgumentError` instead of `::ArgumentError` when filter has wrong number of arguments #309 [Bogdan Gusiev, bogdan]
40
- * Add a to_s default for liquid drops, see #306 [Adam Doeler, releod]
41
- * Add strip, lstrip, and rstrip to standard filters [Florian Weingarten, fw42]
42
- * Make if, for & case tags return complete and consistent nodelists, see #250 [Nick Jones, dntj]
43
- * Prevent arbitrary method invocation on condition objects, see #274 [Dylan Thacker-Smith, dylanahsmith]
44
- * Don't call to_sym when creating conditions for security reasons, see #273 [Bouke van der Bijl, bouk]
45
- * Fix resource counting bug with respond_to?(:length), see #263 [Florian Weingarten, fw42]
46
- * Allow specifying custom patterns for template filenames, see #284 [Andrei Gladkyi, agladkyi]
47
- * Allow drops to optimize loading a slice of elements, see #282 [Tom Burns, boourns]
48
- * Support for passing variables to snippets in subdirs, see #271 [Joost Hietbrink, joost]
49
- * Add a class cache to avoid runtime extend calls, see #249 [James Tucker, raggi]
50
- * Remove some legacy Ruby 1.8 compatibility code, see #276 [Florian Weingarten, fw42]
51
- * Add default filter to standard filters, see #267 [Derrick Reimer, djreimer]
52
- * Add optional strict parsing and warn parsing, see #235 [Tristan Hume, trishume]
53
- * Add I18n syntax error translation, see #241 [Simon Hørup Eskildsen, Sirupsen]
54
- * Make sort filter work on enumerable drops, see #239 [Florian Weingarten, fw42]
55
- * Fix clashing method names in enumerable drops, see #238 [Florian Weingarten, fw42]
56
- * Make map filter work on enumerable drops, see #233 [Florian Weingarten, fw42]
57
- * Improved whitespace stripping for blank blocks, related to #216 [Florian Weingarten, fw42]
211
+ * Removed Block#end_tag. Instead, override parse with `super` followed by your code. See #446 [Dylan Thacker-Smith]
212
+ * Fixed condition with wrong data types (#423) [Bogdan Gusiev]
213
+ * Add url_encode to standard filters (#421) [Derrick Reimer]
214
+ * Add uniq to standard filters [Florian Weingarten]
215
+ * Add exception_handler feature (#397) and #254 [Bogdan Gusiev, Florian Weingarten]
216
+ * Optimize variable parsing to avoid repeated regex evaluation during template rendering #383 [Jason Hiltz-Laforge]
217
+ * Optimize checking for block interrupts to reduce object allocation #380 [Jason Hiltz-Laforge]
218
+ * Properly set context rethrow_errors on render! #349 [Thierry Joyal]
219
+ * Fix broken rendering of variables which are equal to false (#345) [Florian Weingarten]
220
+ * Remove ActionView template handler [Dylan Thacker-Smith]
221
+ * Freeze lots of string literals for new Ruby 2.1 optimization (#297) [Florian Weingarten]
222
+ * Allow newlines in tags and variables (#324) [Dylan Thacker-Smith]
223
+ * Tag#parse is called after initialize, which now takes options instead of tokens as the 3rd argument. See #321 [Dylan Thacker-Smith]
224
+ * Raise `Liquid::ArgumentError` instead of `::ArgumentError` when filter has wrong number of arguments #309 [Bogdan Gusiev]
225
+ * Add a to_s default for liquid drops (#306) [Adam Doeler]
226
+ * Add strip, lstrip, and rstrip to standard filters [Florian Weingarten]
227
+ * Make if, for & case tags return complete and consistent nodelists (#250) [Nick Jones]
228
+ * Prevent arbitrary method invocation on condition objects (#274) [Dylan Thacker-Smith]
229
+ * Don't call to_sym when creating conditions for security reasons (#273) [Bouke van der Bijl]
230
+ * Fix resource counting bug with respond_to?(:length) (#263) [Florian Weingarten]
231
+ * Allow specifying custom patterns for template filenames (#284) [Andrei Gladkyi]
232
+ * Allow drops to optimize loading a slice of elements (#282) [Tom Burns]
233
+ * Support for passing variables to snippets in subdirs (#271) [Joost Hietbrink]
234
+ * Add a class cache to avoid runtime extend calls (#249) [James Tucker]
235
+ * Remove some legacy Ruby 1.8 compatibility code (#276) [Florian Weingarten]
236
+ * Add default filter to standard filters (#267) [Derrick Reimer]
237
+ * Add optional strict parsing and warn parsing (#235) [Tristan Hume]
238
+ * Add I18n syntax error translation (#241) [Simon Hørup Eskildsen, Sirupsen]
239
+ * Make sort filter work on enumerable drops (#239) [Florian Weingarten]
240
+ * Fix clashing method names in enumerable drops (#238) [Florian Weingarten]
241
+ * Make map filter work on enumerable drops (#233) [Florian Weingarten]
242
+ * Improved whitespace stripping for blank blocks, related to #216 [Florian Weingarten]
58
243
 
59
244
  ## 2.6.3 / 2015-07-23 / branch "2-6-stable"
60
245
 
@@ -67,8 +252,8 @@
67
252
  ## 2.6.1 / 2014-01-10
68
253
 
69
254
  Security fix, cherry-picked from master (4e14a65):
70
- * Don't call to_sym when creating conditions for security reasons, see #273 [Bouke van der Bijl, bouk]
71
- * Prevent arbitrary method invocation on condition objects, see #274 [Dylan Thacker-Smith, dylanahsmith]
255
+ * Don't call to_sym when creating conditions for security reasons (#273) [Bouke van der Bijl]
256
+ * Prevent arbitrary method invocation on condition objects (#274) [Dylan Thacker-Smith]
72
257
 
73
258
  ## 2.6.0 / 2013-11-25
74
259
 
@@ -76,37 +261,37 @@ IMPORTANT: Liquid 2.6 is going to be the last version of Liquid which maintains
76
261
  The following releases will only be tested against Ruby 1.9 and Ruby 2.0 and are likely to break on Ruby 1.8.
77
262
 
78
263
  * Bugfix for #106: fix example servlet [gnowoel]
79
- * Bugfix for #97: strip_html filter supports multi-line tags [Jo Liss, joliss]
80
- * Bugfix for #114: strip_html filter supports style tags [James Allardice, jamesallardice]
81
- * Bugfix for #117: 'now' support for date filter in Ruby 1.9 [Notre Dame Webgroup, ndwebgroup]
82
- * Bugfix for #166: truncate filter on UTF-8 strings with Ruby 1.8 [Florian Weingarten, fw42]
83
- * Bugfix for #204: 'raw' parsing bug [Florian Weingarten, fw42]
84
- * Bugfix for #150: 'for' parsing bug [Peter Schröder, phoet]
85
- * Bugfix for #126: Strip CRLF in strip_newline [Peter Schröder, phoet]
86
- * Bugfix for #174, "can't convert Fixnum into String" for "replace" [wǒ_is神仙, jsw0528]
87
- * Allow a Liquid::Drop to be passed into Template#render [Daniel Huckstep, darkhelmet]
88
- * Resource limits [Florian Weingarten, fw42]
89
- * Add reverse filter [Jay Strybis, unreal]
264
+ * Bugfix for #97: strip_html filter supports multi-line tags [Jo Liss]
265
+ * Bugfix for #114: strip_html filter supports style tags [James Allardice]
266
+ * Bugfix for #117: 'now' support for date filter in Ruby 1.9 [Notre Dame Webgroup]
267
+ * Bugfix for #166: truncate filter on UTF-8 strings with Ruby 1.8 [Florian Weingarten]
268
+ * Bugfix for #204: 'raw' parsing bug [Florian Weingarten]
269
+ * Bugfix for #150: 'for' parsing bug [Peter Schröder]
270
+ * Bugfix for #126: Strip CRLF in strip_newline [Peter Schröder]
271
+ * Bugfix for #174, "can't convert Fixnum into String" for "replace" [jsw0528]
272
+ * Allow a Liquid::Drop to be passed into Template#render [Daniel Huckstep]
273
+ * Resource limits [Florian Weingarten]
274
+ * Add reverse filter [Jay Strybis]
90
275
  * Add utf-8 support
91
- * Use array instead of Hash to keep the registered filters [Tasos Stathopoulos, astathopoulos]
92
- * Cache tokenized partial templates [Tom Burns, boourns]
93
- * Avoid warnings in Ruby 1.9.3 [Marcus Stollsteimer, stomar]
94
- * Better documentation for 'include' tag (closes #163) [Peter Schröder, phoet]
95
- * Use of BigDecimal on filters to have better precision (closes #155) [Arthur Nogueira Neves, arthurnn]
276
+ * Use array instead of Hash to keep the registered filters [Tasos Stathopoulos]
277
+ * Cache tokenized partial templates [Tom Burns]
278
+ * Avoid warnings in Ruby 1.9.3 [Marcus Stollsteimer]
279
+ * Better documentation for 'include' tag (closes #163) [Peter Schröder]
280
+ * Use of BigDecimal on filters to have better precision (closes #155) [Arthur Nogueira Neves]
96
281
 
97
282
  ## 2.5.5 / 2014-01-10 / branch "2-5-stable"
98
283
 
99
284
  Security fix, cherry-picked from master (4e14a65):
100
- * Don't call to_sym when creating conditions for security reasons, see #273 [Bouke van der Bijl, bouk]
101
- * Prevent arbitrary method invocation on condition objects, see #274 [Dylan Thacker-Smith, dylanahsmith]
285
+ * Don't call to_sym when creating conditions for security reasons (#273) [Bouke van der Bijl]
286
+ * Prevent arbitrary method invocation on condition objects (#274) [Dylan Thacker-Smith]
102
287
 
103
288
  ## 2.5.4 / 2013-11-11
104
289
 
105
- * Fix "can't convert Fixnum into String" for "replace", see #173, [wǒ_is神仙, jsw0528]
290
+ * Fix "can't convert Fixnum into String" for "replace" (#173), [jsw0528]
106
291
 
107
292
  ## 2.5.3 / 2013-10-09
108
293
 
109
- * #232, #234, #237: Fix map filter bugs [Florian Weingarten, fw42]
294
+ * #232, #234, #237: Fix map filter bugs [Florian Weingarten]
110
295
 
111
296
  ## 2.5.2 / 2013-09-03 / deleted
112
297
 
@@ -114,7 +299,7 @@ Yanked from rubygems, as it contained too many changes that broke compatibility.
114
299
 
115
300
  ## 2.5.1 / 2013-07-24
116
301
 
117
- * #230: Fix security issue with map filter, Use invoke_drop in map filter [Florian Weingarten, fw42]
302
+ * #230: Fix security issue with map filter, Use invoke_drop in map filter [Florian Weingarten]
118
303
 
119
304
  ## 2.5.0 / 2013-03-06
120
305
 
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  * [Contributing guidelines](CONTRIBUTING.md)
7
7
  * [Version history](History.md)
8
- * [Liquid documentation from Shopify](http://docs.shopify.com/themes/liquid-basics)
8
+ * [Liquid documentation from Shopify](https://shopify.dev/api/liquid)
9
9
  * [Liquid Wiki at GitHub](https://github.com/Shopify/liquid/wiki)
10
10
  * [Website](http://liquidmarkup.org/)
11
11
 
@@ -42,6 +42,8 @@ Liquid is a template engine which was written with very specific requirements:
42
42
 
43
43
  ## How to use Liquid
44
44
 
45
+ Install Liquid by adding `gem 'liquid'` to your gemfile.
46
+
45
47
  Liquid supports a very simple API based around the Liquid::Template class.
46
48
  For standard use you can just pass it the content of a file and call render with a parameters hash.
47
49
 
@@ -54,22 +56,59 @@ For standard use you can just pass it the content of a file and call render with
54
56
 
55
57
  Setting the error mode of Liquid lets you specify how strictly you want your templates to be interpreted.
56
58
  Normally the parser is very lax and will accept almost anything without error. Unfortunately this can make
57
- it very hard to debug and can lead to unexpected behaviour.
59
+ it very hard to debug and can lead to unexpected behaviour.
58
60
 
59
61
  Liquid also comes with a stricter parser that can be used when editing templates to give better error messages
60
62
  when templates are invalid. You can enable this new parser like this:
61
63
 
62
64
  ```ruby
63
65
  Liquid::Template.error_mode = :strict # Raises a SyntaxError when invalid syntax is used
64
- Liquid::Template.error_mode = :warn # Adds errors to template.errors but continues as normal
66
+ Liquid::Template.error_mode = :warn # Adds strict errors to template.errors but continues as normal
65
67
  Liquid::Template.error_mode = :lax # The default mode, accepts almost anything.
66
68
  ```
67
69
 
68
70
  If you want to set the error mode only on specific templates you can pass `:error_mode` as an option to `parse`:
69
71
  ```ruby
70
- Liquid::Template.parse(source, :error_mode => :strict)
72
+ Liquid::Template.parse(source, error_mode: :strict)
71
73
  ```
72
74
  This is useful for doing things like enabling strict mode only in the theme editor.
73
75
 
74
76
  It is recommended that you enable `:strict` or `:warn` mode on new apps to stop invalid templates from being created.
75
77
  It is also recommended that you use it in the template editors of existing apps to give editors better error messages.
78
+
79
+ ### Undefined variables and filters
80
+
81
+ By default, the renderer doesn't raise or in any other way notify you if some variables or filters are missing, i.e. not passed to the `render` method.
82
+ You can improve this situation by passing `strict_variables: true` and/or `strict_filters: true` options to the `render` method.
83
+ When one of these options is set to true, all errors about undefined variables and undefined filters will be stored in `errors` array of a `Liquid::Template` instance.
84
+ Here are some examples:
85
+
86
+ ```ruby
87
+ template = Liquid::Template.parse("{{x}} {{y}} {{z.a}} {{z.b}}")
88
+ template.render({ 'x' => 1, 'z' => { 'a' => 2 } }, { strict_variables: true })
89
+ #=> '1 2 ' # when a variable is undefined, it's rendered as nil
90
+ template.errors
91
+ #=> [#<Liquid::UndefinedVariable: Liquid error: undefined variable y>, #<Liquid::UndefinedVariable: Liquid error: undefined variable b>]
92
+ ```
93
+
94
+ ```ruby
95
+ template = Liquid::Template.parse("{{x | filter1 | upcase}}")
96
+ template.render({ 'x' => 'foo' }, { strict_filters: true })
97
+ #=> '' # when at least one filter in the filter chain is undefined, a whole expression is rendered as nil
98
+ template.errors
99
+ #=> [#<Liquid::UndefinedFilter: Liquid error: undefined filter filter1>]
100
+ ```
101
+
102
+ If you want to raise on a first exception instead of pushing all of them in `errors`, you can use `render!` method:
103
+
104
+ ```ruby
105
+ template = Liquid::Template.parse("{{x}} {{y}}")
106
+ template.render!({ 'x' => 1}, { strict_variables: true })
107
+ #=> Liquid::UndefinedVariable: Liquid error: undefined variable y
108
+ ```
109
+
110
+ ### Usage tracking
111
+
112
+ To help track usages of a feature or code path in production, we have released opt-in usage tracking. To enable this, we provide an empty `Liquid:: Usage.increment` method which you can customize to your needs. The feature is well suited to https://github.com/Shopify/statsd-instrument. However, the choice of implementation is up to you.
113
+
114
+ Once you have enabled usage tracking, we recommend reporting any events through Github Issues that your system may be logging. It is highly likely this event has been added to consider deprecating or improving code specific to this event, so please raise any concerns.