Issues around using Wild mode
frikky opened this issue · 3 comments
Hey!
We've been running wild mode for Shuffle, and have noticed some inconsistencies in how certain parts run. Here's an example:
We want to get a date from Liquid, hence we run something like this, which works:
{{ "now" | date: "%Y-%m-%d %H:%M" }}
Now we're looking to add e.g. 1 day to it, hence add 86400 (before we will format it). This does NOT work for some reason.
{{ "now" | date: "%s" | plus: 86400 }}
We tested it manually as well - this DOES work.
{{ 1632489029 | plus: 86400 | plus: 86400 }}
Could you tell us what the difference between the two is?
On top of this, we have some issues using e.g. {% python %}, where it's simply not running. What kind of information are you interested in here? Anything we can share?
It works for so much, just a bit more to go before it works perfectly - thanks a lot!
This is because date
filter returns a formatted string. Now the date
filter returns a builtin DateTime
object, which allows +/-
(add/sub
) operations with integers interpreted as seconds.
{{ "now" | date: "%Y-%m-%d %H:%M" }}
# '2021-09-24 12:54'
{{ "now" | date: "%Y-%m-%d %H:%M" | plus: 86400 }}
# '2021-09-25 12:54'
{{ "now" | date: "%Y-%m-%d %H:%M" | plus: 86400 }}
# '2021-09-23 12:54'
This feature will be released with 0.7.1
For {% python %}
tag, could you provide some minimal examples that are not running?
I have added some tests for it, see below for its basic uses:
https://github.com/pwwang/liquidpy/blob/dev/tests/wild/test_wild_tags.py
Thanks a lot for the quick help! I also saw that you added regex_replace which will be of great help. I'll make sure to share when we start playing more with the {% python %} mode.
We'll be writing up some documentation soon for how to do basic things for our users too. We'll make sure to share it to make this library more useful for everyone.
Thanks for the great work! Looking forward to that release 💯