Samuel
9672ed5285
Add a new {% render %} tag
...
Example:
```
// the_count.liquid
{{ number }}! Ah ah ah.
// my_template.liquid
{% for number in range (1..3) %}
{% render "the_count", number: number %}
{% endfor %}
Output:
1! Ah ah ah.
2! Ah ah ah.
3! Ah ah ah.
```
The `render` tag is a more strict version of the `include` tag. It is
designed to isolate itself from the parent rendering context both by
creating a new scope (which does not inherit the parent scope) and by
only inheriting "static" registers.
Static registers are those that do not hold mutable state which could
affect rendering. This again helps `render`ed templates remain entirely
separate from their calling context.
Unlike `include`, `render` does not permit specifying the target
template using a variable, only a string literal. For example, this
means that `{% render my_dynamic_template %}` is invalid syntax. This
will make it possible to statically analyze the dependencies between
templates without making Turing angry.
Note that the `static_environment` of a rendered template is inherited, unlike
the scope and regular environment. This environment is immutable from within the
template.
An alternate syntax, which mimics the `{% include ... for %}` tag is
currently in design discussion.
2019-08-29 16:32:05 -04:00
Samuel
d338ccb9a6
Add isolated subcontexts
...
An isolated subcontext inherits the environment, filters,
and static registers of its supercontext, but with a fresh
(isolated) scope.
This will pave the way for adding the `render` tag, which renders
templates in such a subcontext.
2019-08-29 10:27:15 -04:00
Mike Angell
8f68cffdf1
Resolve failing rubocop issues
2019-08-29 00:45:38 +10:00
Mike Angell
cf4e77ab0c
Merge branch 'master' into bump-ruby-2-4
2019-08-29 00:24:45 +10:00
Tobias Lütke
6eab595fae
Merge pull request #1086 from Shopify/liquid-tag
...
Add {% liquid %} and {% echo %} tags
2019-08-27 15:10:20 -04:00
Mike Angell
b16b109a80
Bump Minimum version to 2.4 and bump Rubocop
2019-08-28 00:31:44 +10:00
Florian Weingarten
248c54a386
Merge pull request #1091 from Shopify/rendering-with-less-garbage
...
Rendering with less garbage
2019-07-19 15:53:22 +01:00
Florian Weingarten
9640e77805
render_to_output_buffer
2019-04-23 17:06:29 -04:00
David Cornu
70ed1fc86d
Make sure the limit and offset values are integers
2019-04-23 16:44:37 -04:00
Florian Weingarten
2a1ca3152d
liquid without the garbage
2019-04-22 16:34:31 -04:00
Florian Weingarten
c89ce9c2ed
use bytesize, not length
2019-04-17 18:55:13 +01:00
Justin Li
e6ed804ca5
Fix line number tracking after a non-empty blank token
2019-04-08 18:43:09 -04:00
Justin Li
951abb67ee
Remove {% local %} tag
2019-04-08 18:34:39 -04:00
Justin Li
8d1cd41453
Add {% liquid %}, {% echo %}, and {% local %} tags
2019-04-01 20:08:38 -04:00
Justin Li
39fecd06db
Fix interrupts through includes
2019-03-12 12:18:22 -04:00
Clayton Smith
e2d9907df2
Validate the character encoding in url_decode.
2019-03-07 14:01:10 -05:00
Justin Li
23d669f5e6
Merge pull request #1032 from printercu/patch-1
...
Single regexp for strip_html
2019-02-22 13:04:04 -05:00
Justin Li
ed73794f82
Preserve existing strip_html behaviour for weird inputs
2019-02-22 13:00:36 -05:00
Ashwin Maroli
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
Garland Zhang
cec27ea326
Extract raise error line and some filters with begin/rescue blocks
2019-02-21 17:00:20 -05:00
Stephen Paul Weber (Work)
fe4034ccf9
Merge pull request #1025 from Shopify/traverse-ast
...
Liquid::ParseTreeVisitor
2018-10-18 09:42:56 -04:00
Stephen Paul Weber
8217a8d86c
Add test for the full array structure
2018-10-18 09:39:05 -04: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
Stephen Paul Weber
d789ec4175
Liquid::Traversal
...
This enables traversal over whole document tree.
2018-10-15 10:11:58 -04:00
Samuel Doiron
fd09f049b0
Merge pull request #1026 from Shopify/where-filter
...
Add `where` filter to standard filters
2018-10-11 17:45:30 -04:00
Samuel
842986a972
Add where filter to standard filters
...
Users of Liquid will often wish to filter an array to only those items that match a certain criteria. For example, showing "pinned" messages at the top of a list.
Example usage:
`{{ comments | where: "pinned" | first }}`
or
`{{ products | where: "category", "kitchen" }}`
* Add where filter to standard filters
* Add tests for new where functionality
2018-10-11 16:52:32 -04:00
Justin Li
cd5a6dd225
Merge pull request #930 from er1/fix-sort-natural-on-nil
...
Fix sort and sort_natural on sorting with non-string and nil values
2018-10-04 22:32:37 -04:00
Dylan Thacker-Smith
4369fe6c85
Improve the unexpected end delimiter message for block tags. ( #1003 )
2018-04-05 11:18:13 -04:00
Dylan Thacker-Smith
5106466a2d
Add a regression test for a liquid-c trim mode bug ( #972 )
2018-01-25 10:55:01 -05:00
Thibaut Courouble
147d7ae24d
Rename min/max filters for clarity
2017-12-06 09:48:30 -05:00
Thibaut Courouble
282d42f98d
Fix min/max filters
2017-12-06 08:58:05 -05:00
Justin Li
e6ba6ee87b
Revert "Use replacement string for replace filters literally ( #924 )"
...
This reverts commit 27c91203ab .
2017-12-04 15:07:59 -05:00
Nithin Bekal
4bdaaf069f
Add max/min filters
2017-11-30 13:56:37 -05:00
Justin Li
a7c5e247c8
Bump rubocop
2017-11-22 11:59:06 -05:00
Eric Chan
deb10ebc7a
Sorting support for data with undefined values
2017-09-14 02:00:43 -04:00
Eric Chan
cfe1844de9
Added test coverage for sort_natural
2017-09-13 22:17:59 -04:00
Dylan Thacker-Smith
27c91203ab
Use replacement string for replace filters literally ( #924 )
2017-08-28 11:51:20 -04:00
Justin Li
44eaa4b9d8
Merge pull request #920 from Shopify/symbol_to_liquid
...
Support rendering symbols as strings
2017-08-18 12:10:53 -04:00
Pascal Betz
a979b3ec95
Do not raise when variable is defined but nil when using strict_variables
2017-08-18 12:09:57 -04:00
Justin Li
bf3e759da3
Support rendering symbols as strings
2017-08-17 23:10:57 -04:00
Thierry Joyal
e340803d12
CGI powered standard filters to handle non string inputs
2017-05-25 15:53:41 +00:00
Dylan Thacker-Smith
48a6d86ac2
Use stackprof to test to lack of object allocations ( #896 )
2017-05-12 09:20:51 -04:00
Dylan Thacker-Smith
3bb29d5456
Replace assert_equal nil, with a assert_nil ( #895 )
2017-05-11 14:05:03 -04:00
Dylan Thacker-Smith
9c72ccb82f
Limit how much blocks can be nested during parsing ( #894 )
2017-05-11 09:37:53 -04:00
Mike Angell
c9bac9befe
Merge branch 'master' into contains-strict-fix
2017-03-24 11:09:09 +10:00
Lasse Skindstad Ebert
5149cde5c3
Fix include tag used with strict_variables ( #829 )
...
Fixes https://github.com/Shopify/liquid/issues/828
2017-03-22 16:00:31 -04:00
chenxianyu
4318240ae0
test: modify Strainer.add_filter duplicate inclusion test case
2017-02-22 10:33:22 +08:00
chenxianyu
aa79c33dda
fix: Strainer.add_filter method
2017-02-13 15:50:19 +08:00
Richard Monette
d17f86ba4d
handle join on fixnum
2017-02-01 12:47:35 -05:00