You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGES.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
## Version 2.2.0 (unreleased)
4
4
5
5
- Added the `squish` filter. `{{ x | squish }}` is equivalent to `{{ x | strip | split | join }}`. See [#195](https://github.com/jg-rp/liquid/pull/195).
6
+
- Added `BoundTemplate.comments()` and `BoundTemplate.docs()` for statically retrieving `{% comment %}`, `{% # inline comment %}` and `{% doc %}` nodes.
6
7
- Added an **experimental**`{% snippet %}` tag. Shopify/liquid released then quickly removed `{% snippet %}`. We're calling it "experimental" and keeping it disabled by default, pending more activity from Shopify/liquid. See [#191](https://github.com/jg-rp/liquid/pull/191) and [#193](https://github.com/jg-rp/liquid/pull/193).
7
8
- Improved static analysis of partial templates. Previously we would visit a partial template only once, regardless of how many times it is rendered with `{% render %}`. Now we visit partial templates once for each distinct set of arguments passed to `{% render %}`, potentially reporting "global" variables that we'd previously missed.
8
9
- Changed the `string_filter` decorator to coerce `None` to an empty string instead of `"None"`. This is what Shopify/liquid does with `nil.to_s`.
Copy file name to clipboardExpand all lines: docs/known_issues.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ The built-in [`date`](filter_reference.md#date) filter uses [dateutil](https://d
32
32
33
33
Python Liquid might not handle syntax or type errors in the same way as the reference implementation. We might fail earlier or later, and will almost certainly produce a different error message.
34
34
35
-
Python Liquid does not have a "lax" parser, like Ruby Liquid. If the lexer encounters unknown symbols, a `LiquidSyntaxError` is raised. Upon finding an error in [lax mode](/introduction/strictness), the parser simply discards the current block and continues to to the next block, if one is available. Also, Python Liquid will never inject error messages into an output document.
35
+
Python Liquid does not have a "lax" parser, like Ruby Liquid. If the lexer encounters unknown symbols, a `LiquidSyntaxError` is raised. Upon finding an error in [lax mode](environment.md#tolerance), the parser simply discards the current block and continues to to the next block, if one is available. Also, Python Liquid will never inject error messages into an output document.
Copy file name to clipboardExpand all lines: docs/static_analysis.md
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,3 +140,38 @@ print(template.tag_names())
140
140
## Variable, tag and filter locations
141
141
142
142
[`analyze()`](api/template.md#liquid.BoundTemplate.analyze) and [`analyze_async()`](api/template.md#liquid.BoundTemplate.analyze_async) return an instance of [`TemplateAnalysis`](api/template.md#liquid.static_analysis.TemplateAnalysis). It contains all of the information provided by the methods described above, but includes the location of each variable, tag and filter, each of which can appear many times across many templates.
143
+
144
+
## Comment and doc nodes
145
+
146
+
**_New in version 2.2.0_**
147
+
148
+
[`comments()`](api/template.md#liquid.BoundTemplate.comments) and [`docs()`](api/template.md#liquid.BoundTemplate.docs) return a list of `CommentNode` and `DocNode` instances, respectively. Both have `token` and `text` properties.
149
+
150
+
```python
151
+
from liquid import parse
152
+
153
+
source ="""\
154
+
{% doc %}
155
+
some doc comment
156
+
{% enddoc %}
157
+
158
+
Hello!
159
+
160
+
{% comment %}
161
+
some comment
162
+
{% endcomment %}
163
+
164
+
{% if false %}
165
+
{% # an inline comment %}
166
+
{% endif %}
167
+
"""
168
+
169
+
template = parse(source)
170
+
print([node.text for node in template.comments()])
Copy file name to clipboardExpand all lines: docs/tag_reference.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,16 @@ Inside [liquid tags](#liquid), any line starting with a hash will be considered
46
46
%}
47
47
```
48
48
49
+
### Doc comments
50
+
51
+
**_New in version 2.0.0_**
52
+
53
+
```liquid2
54
+
{% doc %} ... {% enddoc %}
55
+
```
56
+
57
+
Like [block comments](#block-comments), doc comments are not rendered. Doc comments are designed to be read by tooling to improve Liquid template development.
0 commit comments