Skip to content

Commit

Permalink
0.7.2 (#41)
Browse files Browse the repository at this point in the history
* πŸ› Fix date filter issues (#38, #40)

* ✨ Add markdownify for jekyll

* πŸ”– 0.7.2

* πŸ’š Add markdown dep in CI

* βœ… Fix date filter tests

* ✨ Add int, float, str and bool as both filters and globals for all modes

* πŸ“ Update docs for builtin typecasting filters/globals.

* πŸ“ Update docs

* ✨ Add jekyll filter `number_of_words`

* ✨ Add jekyll filter `sort`

* ✨ Add jekyll filter `slugify`

* ✨ Add jekyll filter `array_to_sentence_string`

* ✨ Add jekyll filter `jsonify`

* ✨ Add jekyll filters `xml_escape`, `cgi_escape` and `uri_escape`
  • Loading branch information
pwwang authored Oct 19, 2021
1 parent 3917729 commit 6c3705f
Show file tree
Hide file tree
Showing 11 changed files with 603 additions and 57 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ exclude_lines =
if TYPE_CHECKING:
pragma: no cover
pass
except ImportError:
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ jobs:
poetry install -v
# reinstall pandas to specific version
pip install $JINJA2
pip install regex
pip install markdown
pip install python-dateutil
pip install python-frontmatter
pip install python-slugify
env:
JINJA2: ${{ matrix.jinja2 }}
- name: Test with pytest
Expand Down
30 changes: 30 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,58 @@
# 0.7.2

- πŸ› Fix `date` filter issues (#38, #40)
- ✨ Add `markdownify` for jekyll (#36, #37)
- ✨ Add `number_of_words` for jekyll
- ✨ Add jekyll filter `sort`
- ✨ Add jekyll filter `slugify`
- ✨ Add jekyll filter `array_to_sentence_string`
- ✨ Add jekyll filter `jsonify`
- ✨ Add jekyll filters `xml_escape`, `cgi_escape` and `uri_escape`
- ✨ Add `int`, `float`, `str` and `bool` as both filters and globals for all modes (#40)


# 0.7.1

- ✨ Add `regex_replace` filter
- ✨ Allow absolute path and pathlib.Path passed as template files
- ✨ Allow `+/-` to work with date filter (#38)
- ✨ Add `filters_as_globals` for wild mode (defaults to `True`)

# 0.7.0

- Reimplement using jinja2

# 0.6.4

Last release of 0.6, for compatibilities.

- Add regex_replace filter (#33)

# 0.6.3

- Allow tag for to have output(test | filter) in python mode.
- Fix stacks not print in some cases.
- Avoid closing stream after parsing
- Add better error message for attribute error while rendering
- Print 'KeyError' for render error if it is a KeyError.

# 0.6.2

- Update dependency versions

# 0.6.1

- Fix use of LiquidPython
- Add getitem and render filter for python mode
- Fix EmptyDrop for variable segment in python mode
- Fix re-rendering error for extends tag (#29)

# 0.6.0

- Remodel the package to use a lexer to scan the nodes first and then lark-parse to parse the tag.

# 0.5.0

- Extract major model of node to allow `register_node` (#18)
- Introduce `config` node and deprecate `mode`
- Allow specification of directories to scan for `include` and `extends` (#19)
Expand All @@ -42,31 +63,38 @@ Last release of 0.6, for compatibilities.
- Add API documentations

# 0.4.0

- Implement issue #13: Adding ternary end modifier (`$`)
- Expand list/dict context in debug information

# 0.3.0

- Force explict modifiers (=/!) for True/False action in ternary filters
- Add combined ternary filters
- Add shortcut `?` for `?bool`
- Use the maximum lineno on traceback instead of the last one.

# 0.2.3

- Fix parsing errors when unicode in a template loaded from text #10 (thanks to vermeeca)

# 0.2.2

- Show shortened context in debug information
- Fix #9: stream cursor shifted when unicode in the template.

# 0.2.1

- Fix #7: forloop problem with nesting for statements
- Fix other bugs

# 0.2.0

- Add inclusion and inheritance support
- Add `cycle` for `for` loop

# 0.1.0

- Rewrite whole engine using a stream parser
- Support multi-line for statements, expressions and tag comments (#1)
- Support wrapper (instead of a single prefix) for statement comments
Expand All @@ -79,9 +107,11 @@ Last release of 0.6, for compatibilities.
- Remove `&` modifiers

# 0.0.7

- Allow `{% mode %}` block to be anywhere in the source code
- Full the coverage
- Change support only for python3.5+

# 0.0.6

- Add modifiers `&` and `*` to allow chaining and expanding arguments
60 changes: 48 additions & 12 deletions docs/standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,51 @@ You may checkout the documentation for standard liquid:

`liquidpy` tries to maintain the maximum compatibility with `liquid`. But we do have some differences:

- [Filter] `round()` always returns a `float` rather than an `integer` when `ndigits=0`
- [Operator] The logical operators `and`/`or` collapse from left to right (it's right to left in `liquid`)
- See: https://shopify.github.io/liquid/basics/operators/#order-of-operations
- [Truthy and falsy] Instead of always truthy for empty string, 0, empty array, they are falsy in `liquidpy`
- [Iteration] Literal ranges (`(1..5)`) are suported by `liquidpy`. However, the start and the stop must be integers or names, meaning this is not supported `(1..array.size)`. You can do this instead:

```liquid
{% assign asize = array.size %}
{% for i in (1..asize) %}
...
{% endfor %}
```
## Filter `round()`

It always returns a `float` rather than an `integer` when `ndigits=0`


## Logical operators

The logical operators `and`/`or` collapse from left to right (it's right to left in `liquid`)

See: https://shopify.github.io/liquid/basics/operators/#order-of-operations


## Truthy and falsy

Instead of always truthy for empty string, 0, empty array, they are falsy in `liquidpy`


## Iteration

Literal ranges (`(1..5)`) are suported by `liquidpy`. However, the start and the stop must be integers or names, meaning this is not supported `(1..array.size)`. You can do this instead:

```liquid
{% assign asize = array.size %}
{% for i in (1..asize) %}
...
{% endfor %}
```

## Typecasting

You are able to do the following in ruby liquid:
```liquid
{{ "1" | plus: 1}} # 2
```
However, this is not valid in liquidpy. Because the template is eventually compiled into python code and the type handling is delegated to python, but "1" + 1 is not a valid python operation.

So you have to do typecasting yourself:
```liquid
{{ "1" | int | plus: 1 }} # 2
```

In order to make it work, extra filters `int`, `float`, `str` and `bool` are added as builtin filters. They are also added as globals in order to get this work:
```liquid
{% capture lst_size %}4{% endcapture %}
{{ 2 | at_most: int(lst_size) }} # 2
```

See also: https://github.com/pwwang/liquidpy/issues/40
2 changes: 1 addition & 1 deletion liquid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

patch_jinja()

__version__ = "0.7.1"
__version__ = "0.7.2"
Loading

0 comments on commit 6c3705f

Please sign in to comment.